<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>API: button   button.js  (YUI Library)</title>
	<link rel="stylesheet" type="text/css" href="assets/api.css">
    <script type="text/javascript" src="assets/api-js"></script>
    <script type="text/javascript" src="assets/ac-js"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">

	<div id="hd">
        <a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
        <h3>Button&nbsp; <span class="subtitle">2.3.1</span></h3>
        <p>
        <a href="./index.html">Yahoo! UI Library</a> 
            &gt; <a href="./module_button.html">button</a>
                
                 &gt; button.js (source view) 
            </p>

	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form name="yui-classopts-form">
    <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> Show Private</span>
    <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> Show Protected</span>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 #classopts { display:none; }
                        </style>
<div class="highlight" ><pre><span class="c">/**</span>
<span class="c">* @module button</span>
<span class="c">* @description &lt;p&gt;The Button Control enables the creation of rich, graphical </span>
<span class="c">* buttons that function like traditional HTML form buttons.  &lt;em&gt;Unlike&lt;/em&gt; </span>
<span class="c">* tradition HTML form buttons, buttons created with the Button Control can have </span>
<span class="c">* a label that is different from its value.  With the inclusion of the optional </span>
<span class="c">* &lt;a href=&quot;module_menu.html&quot;&gt;Menu Control&lt;/a&gt;, the Button Control can also be</span>
<span class="c">* used to create menu buttons and split buttons, controls that are not </span>
<span class="c">* available natively in HTML.  The Button Control can also be thought of as a </span>
<span class="c">* way to create more visually engaging implementations of the browser&#39;s </span>
<span class="c">* default radio-button and check-box controls.&lt;/p&gt;</span>
<span class="c">* &lt;p&gt;The Button Control supports the following types:&lt;/p&gt;</span>
<span class="c">* &lt;dl&gt;</span>
<span class="c">* &lt;dt&gt;push&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Basic push button that can execute a user-specified command when </span>
<span class="c">* pressed.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;link&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Navigates to a specified url when pressed.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;submit&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Submits the parent form when pressed.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;reset&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Resets the parent form when pressed.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;checkbox&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Maintains a &quot;checked&quot; state that can be toggled on and off.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;radio&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Maintains a &quot;checked&quot; state that can be toggled on and off.  Use with </span>
<span class="c">* the ButtonGroup class to create a set of controls that are mutually </span>
<span class="c">* exclusive; checking one button in the set will uncheck all others in </span>
<span class="c">* the group.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;menu&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;When pressed will show/hide a menu.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;split&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Can execute a user-specified command or display a menu when pressed.&lt;/dd&gt;</span>
<span class="c">* &lt;/dl&gt;</span>
<span class="c">* @title Button</span>
<span class="c">* @namespace YAHOO.widget</span>
<span class="c">* @requires yahoo, dom, element, event</span>
<span class="c">* @optional container, menu</span>
<span class="c">* @beta</span>
<span class="c">*/</span>


<span class="o">(</span><span class="k">function</span> <span class="o">()</span> <span class="o">{</span>


    <span class="c">/**</span>
<span class="c">    * The Button class creates a rich, graphical button.</span>
<span class="c">    * @param {String} p_oElement String specifying the id attribute of the </span>
<span class="c">    * &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt;, &lt;code&gt;&amp;#60;button&amp;#62;&lt;/code&gt;,</span>
<span class="c">    * &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt;, or &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt; element to </span>
<span class="c">    * be used to create the button.</span>
<span class="c">    * @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">    * one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;|&lt;a href=&quot;http://www.w3.org</span>
<span class="c">    * /TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-34812697&quot;&gt;</span>
<span class="c">    * HTMLButtonElement&lt;/a&gt;|&lt;a href=&quot;</span>
<span class="c">    * http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#</span>
<span class="c">    * ID-33759296&quot;&gt;HTMLElement&lt;/a&gt;} p_oElement Object reference for the </span>
<span class="c">    * &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt;, &lt;code&gt;&amp;#60;button&amp;#62;&lt;/code&gt;, </span>
<span class="c">    * &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt;, or &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt; element to be </span>
<span class="c">    * used to create the button.</span>
<span class="c">    * @param {Object} p_oElement Object literal specifying a set of   </span>
<span class="c">    * configuration attributes used to create the button.</span>
<span class="c">    * @param {Object} p_oAttributes Optional. Object literal specifying a set  </span>
<span class="c">    * of configuration attributes used to create the button.</span>
<span class="c">    * @namespace YAHOO.widget</span>
<span class="c">    * @class Button</span>
<span class="c">    * @constructor</span>
<span class="c">    * @extends YAHOO.util.Element</span>
<span class="c">    */</span>



    <span class="c">// Shorthard for utilities</span>
<span class="c"></span>
    <span class="k">var</span> <span class="nx">Dom</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span>
        <span class="nx">Event</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">,</span>
        <span class="nx">Lang</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">,</span>
        <span class="nx">Overlay</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Overlay</span><span class="o">,</span>
        <span class="nx">Menu</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">,</span>
    
    
        <span class="c">// Private member variables</span>
<span class="c"></span>    
        <span class="nx">m_oButtons</span> <span class="o">=</span> <span class="o">{},</span>    <span class="c">// Collection of all Button instances</span>
<span class="c"></span>        <span class="nx">m_oOverlayManager</span> <span class="o">=</span> <span class="kc">null</span><span class="o">,</span>   <span class="c">// YAHOO.widget.OverlayManager instance</span>
<span class="c"></span>        <span class="nx">m_oSubmitTrigger</span> <span class="o">=</span> <span class="kc">null</span><span class="o">,</span>    <span class="c">// The button that submitted the form </span>
<span class="c"></span>        <span class="nx">m_oFocusedButton</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>    <span class="c">// The button that has focus</span>
<span class="c"></span>


    <span class="c">// Private methods</span>
<span class="c"></span>
    
    
    <span class="c">/**</span>
<span class="c">    * @method createInputElement</span>
<span class="c">    * @description Creates an &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element of the </span>
<span class="c">    * specified type.</span>
<span class="c">    * @private</span>
<span class="c">    * @param {String} p_sType String specifying the type of </span>
<span class="c">    * &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element to create.</span>
<span class="c">    * @param {String} p_sName String specifying the name of </span>
<span class="c">    * &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element to create.</span>
<span class="c">    * @param {String} p_sValue String specifying the value of </span>
<span class="c">    * &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element to create.</span>
<span class="c">    * @param {String} p_bChecked Boolean specifying if the  </span>
<span class="c">    * &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element is to be checked.</span>
<span class="c">    * @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">    * one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;}</span>
<span class="c">    */</span>
    <span class="k">function</span> <span class="nx">createInputElement</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_sName</span><span class="o">,</span> <span class="nx">p_sValue</span><span class="o">,</span> <span class="nx">p_bChecked</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">var</span> <span class="nx">oInput</span><span class="o">,</span>
            <span class="nx">sInput</span><span class="o">;</span>
    
        <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">p_sName</span><span class="o">))</span> <span class="o">{</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">env</span><span class="o">.</span><span class="nx">ua</span><span class="o">.</span><span class="nx">ie</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="c">/*</span>
<span class="c">                    For IE it is necessary to create the element with the </span>
<span class="c">                    &quot;type,&quot; &quot;name,&quot; &quot;value,&quot; and &quot;checked&quot; properties set all </span>
<span class="c">                    at once.</span>
<span class="c">                */</span>
            
                <span class="nx">sInput</span> <span class="o">=</span> <span class="s2">&quot;&lt;input type=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">p_sType</span> <span class="o">+</span> <span class="s2">&quot;\&quot; name=\&quot;&quot;</span> <span class="o">+</span> 
                    <span class="nx">p_sName</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span><span class="o">;</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">p_bChecked</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">sInput</span> <span class="o">+=</span> <span class="s2">&quot; checked&quot;</span><span class="o">;</span>
                
                <span class="o">}</span>
                
                <span class="nx">sInput</span> <span class="o">+=</span> <span class="s2">&quot;&gt;&quot;</span><span class="o">;</span>
        
                <span class="nx">oInput</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="nx">sInput</span><span class="o">);</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
            
                <span class="nx">oInput</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;input&quot;</span><span class="o">);</span>
                <span class="nx">oInput</span><span class="o">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">p_sName</span><span class="o">;</span>
                <span class="nx">oInput</span><span class="o">.</span><span class="nx">type</span> <span class="o">=</span> <span class="nx">p_sType</span><span class="o">;</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">p_bChecked</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">oInput</span><span class="o">.</span><span class="nx">checked</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                
                <span class="o">}</span>
        
            <span class="o">}</span>
        
            <span class="nx">oInput</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">p_sValue</span><span class="o">;</span>
            
            <span class="k">return</span> <span class="nx">oInput</span><span class="o">;</span>
        
        <span class="o">}</span>
    
    <span class="o">}</span>
    
    
    <span class="c">/**</span>
<span class="c">    * @method setAttributesFromSrcElement</span>
<span class="c">    * @description Gets the values for all the attributes of the source element </span>
<span class="c">    * (either &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; or &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt;) that </span>
<span class="c">    * map to Button configuration attributes and sets them into a collection </span>
<span class="c">    * that is passed to the Button constructor.</span>
<span class="c">    * @private</span>
<span class="c">    * @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">    * one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;|&lt;a href=&quot;http://www.w3.org/</span>
<span class="c">    * TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-</span>
<span class="c">    * 48250443&quot;&gt;HTMLAnchorElement&lt;/a&gt;} p_oElement Object reference to the HTML </span>
<span class="c">    * element (either &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; or &lt;code&gt;&amp;#60;span&amp;#62;</span>
<span class="c">    * &lt;/code&gt;) used to create the button.</span>
<span class="c">    * @param {Object} p_oAttributes Object reference for the collection of </span>
<span class="c">    * configuration attributes used to create the button.</span>
<span class="c">    */</span>
    <span class="k">function</span> <span class="nx">setAttributesFromSrcElement</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">,</span> <span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">var</span> <span class="nx">sSrcElementNodeName</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">(),</span>
            <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">,</span>
            <span class="nx">oAttribute</span><span class="o">,</span>
            <span class="nx">oRootNode</span><span class="o">,</span>
            <span class="nx">sText</span><span class="o">;</span>
            
    
        <span class="c">/**</span>
<span class="c">        * @method setAttributeFromDOMAttribute</span>
<span class="c">        * @description Gets the value of the specified DOM attribute and sets it </span>
<span class="c">        * into the collection of configuration attributes used to configure </span>
<span class="c">        * the button.</span>
<span class="c">        * @private</span>
<span class="c">        * @param {String} p_sAttribute String representing the name of the </span>
<span class="c">        * attribute to retrieve from the DOM element.</span>
<span class="c">        */</span>
        <span class="k">function</span> <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="nx">p_sAttribute</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">if</span> <span class="o">(!(</span><span class="nx">p_sAttribute</span> <span class="k">in</span> <span class="nx">p_oAttributes</span><span class="o">))</span> <span class="o">{</span>
    
                <span class="c">/*</span>
<span class="c">                    Need to use &quot;getAttributeNode&quot; instead of &quot;getAttribute&quot; </span>
<span class="c">                    because using &quot;getAttribute,&quot; IE will return the innerText </span>
<span class="c">                    of a &lt;code&gt;&amp;#60;button&amp;#62;&lt;/code&gt; for the value attribute  </span>
<span class="c">                    rather than the value of the &quot;value&quot; attribute.</span>
<span class="c">                */</span>
        
                <span class="nx">oAttribute</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">getAttributeNode</span><span class="o">(</span><span class="nx">p_sAttribute</span><span class="o">);</span>
        
    
                <span class="k">if</span> <span class="o">(</span><span class="nx">oAttribute</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="s2">&quot;value&quot;</span> <span class="k">in</span> <span class="nx">oAttribute</span><span class="o">))</span> <span class="o">{</span>
    
                    <span class="nx">me</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Setting attribute \&quot;&quot;</span> <span class="o">+</span> <span class="nx">p_sAttribute</span> <span class="o">+</span> 
                        <span class="s2">&quot;\&quot; using source element&#39;s attribute value of \&quot;&quot;</span> <span class="o">+</span> 
                        <span class="nx">oAttribute</span><span class="o">.</span><span class="nx">value</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span><span class="o">);</span>
    
                    <span class="nx">p_oAttributes</span><span class="o">[</span><span class="nx">p_sAttribute</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oAttribute</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
    
                <span class="o">}</span>
    
            <span class="o">}</span>
        
        <span class="o">}</span>
    
    
        <span class="c">/**</span>
<span class="c">        * @method setFormElementProperties</span>
<span class="c">        * @description Gets the value of the attributes from the form element  </span>
<span class="c">        * and sets them into the collection of configuration attributes used to </span>
<span class="c">        * configure the button.</span>
<span class="c">        * @private</span>
<span class="c">        */</span>
        <span class="k">function</span> <span class="nx">setFormElementProperties</span><span class="o">()</span> <span class="o">{</span>
    
            <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>
    
            <span class="k">if</span> <span class="o">(</span><span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;button&quot;</span><span class="o">)</span> <span class="o">{</span>
            
                <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">type</span> <span class="o">=</span> <span class="s2">&quot;push&quot;</span><span class="o">;</span>
            
            <span class="o">}</span>
    
            <span class="k">if</span> <span class="o">(!(</span><span class="s2">&quot;disabled&quot;</span> <span class="k">in</span> <span class="nx">p_oAttributes</span><span class="o">))</span> <span class="o">{</span>
    
                <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">disabled</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">disabled</span><span class="o">;</span>
    
            <span class="o">}</span>
    
            <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">);</span>
            <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;value&quot;</span><span class="o">);</span>
            <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">);</span>
    
        <span class="o">}</span>

    
        <span class="nx">switch</span> <span class="o">(</span><span class="nx">sSrcElementNodeName</span><span class="o">)</span> <span class="o">{</span>
        
        <span class="nx">case</span> <span class="s2">&quot;A&quot;</span><span class="o">:</span>
            
            <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">type</span> <span class="o">=</span> <span class="s2">&quot;link&quot;</span><span class="o">;</span>
            
            <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;href&quot;</span><span class="o">);</span>
            <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;target&quot;</span><span class="o">);</span>
        
            <span class="k">break</span><span class="o">;</span>
    
        <span class="nx">case</span> <span class="s2">&quot;INPUT&quot;</span><span class="o">:</span>

            <span class="nx">setFormElementProperties</span><span class="o">();</span>

            <span class="k">if</span> <span class="o">(!(</span><span class="s2">&quot;checked&quot;</span> <span class="k">in</span> <span class="nx">p_oAttributes</span><span class="o">))</span> <span class="o">{</span>
    
                <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">checked</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">checked</span><span class="o">;</span>
    
            <span class="o">}</span>

            <span class="k">break</span><span class="o">;</span>

        <span class="nx">case</span> <span class="s2">&quot;BUTTON&quot;</span><span class="o">:</span>

            <span class="nx">setFormElementProperties</span><span class="o">();</span>

            <span class="nx">oRootNode</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">oRootNode</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span> <span class="o">+</span> <span class="s2">&quot;-checked&quot;</span><span class="o">))</span> <span class="o">{</span>
            
                <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">checked</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            
            <span class="o">}</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">oRootNode</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span> <span class="o">+</span> <span class="s2">&quot;-disabled&quot;</span><span class="o">))</span> <span class="o">{</span>

                <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">disabled</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            
            <span class="o">}</span>

            <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">removeAttribute</span><span class="o">(</span><span class="s2">&quot;value&quot;</span><span class="o">);</span>

            <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">,</span> <span class="s2">&quot;button&quot;</span><span class="o">);</span>

            <span class="k">break</span><span class="o">;</span>
        
        <span class="o">}</span>

        <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">removeAttribute</span><span class="o">(</span><span class="s2">&quot;id&quot;</span><span class="o">);</span>
        <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">removeAttribute</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">);</span>
        
        <span class="k">if</span> <span class="o">(!(</span><span class="s2">&quot;tabindex&quot;</span> <span class="k">in</span> <span class="nx">p_oAttributes</span><span class="o">))</span> <span class="o">{</span>

            <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">tabindex</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">tabIndex</span><span class="o">;</span>

        <span class="o">}</span>
    
        <span class="k">if</span> <span class="o">(!(</span><span class="s2">&quot;label&quot;</span> <span class="k">in</span> <span class="nx">p_oAttributes</span><span class="o">))</span> <span class="o">{</span>
    
            <span class="c">// Set the &quot;label&quot; property</span>
<span class="c"></span>        
            <span class="nx">sText</span> <span class="o">=</span> <span class="nx">sSrcElementNodeName</span> <span class="o">==</span> <span class="s2">&quot;INPUT&quot;</span> <span class="o">?</span> 
                            <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">value</span> <span class="o">:</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">innerHTML</span><span class="o">;</span>
        
    
            <span class="k">if</span> <span class="o">(</span><span class="nx">sText</span> <span class="o">&amp;&amp;</span> <span class="nx">sText</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                
                <span class="nx">p_oAttributes</span><span class="o">.</span><span class="k">label</span> <span class="o">=</span> <span class="nx">sText</span><span class="o">;</span>
                
            <span class="o">}</span> 
    
        <span class="o">}</span>
    
    <span class="o">}</span>
    
    
    <span class="c">/**</span>
<span class="c">    * @method initConfig</span>
<span class="c">    * @description Initializes the set of configuration attributes that are </span>
<span class="c">    * used to instantiate the button.</span>
<span class="c">    * @private</span>
<span class="c">    * @param {Object} Object representing the button&#39;s set of </span>
<span class="c">    * configuration attributes.</span>
<span class="c">    */</span>
    <span class="k">function</span> <span class="nx">initConfig</span><span class="o">(</span><span class="nx">p_oConfig</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">var</span> <span class="nx">oAttributes</span> <span class="o">=</span> <span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">,</span>
            <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">srcelement</span><span class="o">,</span>
            <span class="nx">sSrcElementNodeName</span> <span class="o">=</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">(),</span>
            <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
    
    
        <span class="k">if</span> <span class="o">(</span><span class="nx">sSrcElementNodeName</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">NODE_NAME</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">element</span> <span class="o">=</span> <span class="nx">oSrcElement</span><span class="o">;</span>
            <span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>

            <span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsBy</span><span class="o">(</span><span class="k">function</span> <span class="o">(</span><span class="nx">p_oElement</span><span class="o">)</span> <span class="o">{</span>
            
                <span class="nx">switch</span> <span class="o">(</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">())</span> <span class="o">{</span>
                
                <span class="nx">case</span> <span class="s2">&quot;BUTTON&quot;</span><span class="o">:</span>
                <span class="nx">case</span> <span class="s2">&quot;A&quot;</span><span class="o">:</span>
                <span class="nx">case</span> <span class="s2">&quot;INPUT&quot;</span><span class="o">:</span>

                    <span class="nx">setAttributesFromSrcElement</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">me</span><span class="o">,</span> <span class="nx">p_oElement</span><span class="o">,</span> 
                        <span class="nx">oAttributes</span><span class="o">);</span>

                    <span class="k">break</span><span class="o">;</span>                        
                
                <span class="o">}</span>
            
            <span class="o">},</span> <span class="s2">&quot;*&quot;</span><span class="o">,</span> <span class="nx">oSrcElement</span><span class="o">);</span>
        
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
    
            <span class="nx">switch</span> <span class="o">(</span><span class="nx">sSrcElementNodeName</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">case</span> <span class="s2">&quot;BUTTON&quot;</span><span class="o">:</span>
            <span class="nx">case</span> <span class="s2">&quot;A&quot;</span><span class="o">:</span>
            <span class="nx">case</span> <span class="s2">&quot;INPUT&quot;</span><span class="o">:</span>

                <span class="nx">setAttributesFromSrcElement</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oSrcElement</span><span class="o">,</span> 
                    <span class="nx">oAttributes</span><span class="o">);</span>

                <span class="k">break</span><span class="o">;</span>

            <span class="o">}</span>
        
        <span class="o">}</span>
    
    <span class="o">}</span>



    <span class="c">//  Constructor</span>
<span class="c"></span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span> <span class="o">=</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oElement</span><span class="o">,</span> <span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">var</span> <span class="nx">fnSuperClass</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span><span class="o">,</span>
            <span class="nx">oConfig</span><span class="o">,</span>
            <span class="nx">oElement</span><span class="o">;</span>
    
        <span class="k">if</span> <span class="o">(</span><span class="nx">arguments</span><span class="o">.</span><span class="nx">length</span> <span class="o">==</span> <span class="m">1</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
            <span class="o">!</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">if</span> <span class="o">(!</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">();</span>
    
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;No value specified for the button&#39;s \&quot;id\&quot; &quot;</span> <span class="o">+</span> 
                    <span class="s2">&quot;attribute. Setting button id to \&quot;&quot;</span> <span class="o">+</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> 
                    <span class="s2">&quot;\&quot;.&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">);</span>
    
            <span class="o">}</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">LogWriter</span><span class="o">(</span><span class="s2">&quot;Button &quot;</span> <span class="o">+</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;No source HTML element.  Building the button &quot;</span> <span class="o">+</span>
                    <span class="s2">&quot;using the set of configuration attributes.&quot;</span><span class="o">);</span>
    
            <span class="nx">fnSuperClass</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> 
                <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">createButtonElement</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">type</span><span class="o">)),</span>
                <span class="nx">p_oElement</span><span class="o">);</span>
    
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
    
            <span class="nx">oConfig</span> <span class="o">=</span> <span class="o">{</span> <span class="nx">element</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span> <span class="nx">attributes</span><span class="o">:</span> <span class="o">(</span><span class="nx">p_oAttributes</span> <span class="o">||</span> <span class="o">{})</span> <span class="o">};</span>
    
    
            <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">))</span> <span class="o">{</span>
    
                <span class="nx">oElement</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">);</span>
    
                <span class="k">if</span> <span class="o">(</span><span class="nx">oElement</span><span class="o">)</span> <span class="o">{</span>

                    <span class="k">if</span> <span class="o">(!</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
                    
                        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">;</span>
                    
                    <span class="o">}</span>
    
                    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">LogWriter</span><span class="o">(</span>
                                        <span class="s2">&quot;Button &quot;</span> <span class="o">+</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
                
                    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Building the button using an existing &quot;</span> <span class="o">+</span> 
                            <span class="s2">&quot;HTML element as a source element.&quot;</span><span class="o">);</span>
                
                
                    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">srcelement</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">;</span>
                
                    <span class="nx">initConfig</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">);</span>
                
                
                    <span class="k">if</span> <span class="o">(!</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
                
                        <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Source element could not be used &quot;</span> <span class="o">+</span>
                                <span class="s2">&quot;as is.  Creating a new HTML element for &quot;</span> <span class="o">+</span> 
                                <span class="s2">&quot;the button.&quot;</span><span class="o">);</span>
                
                        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span> <span class="o">=</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">createButtonElement</span><span class="o">(</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">type</span><span class="o">);</span>
                
                    <span class="o">}</span>
                
                    <span class="nx">fnSuperClass</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> 
                        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">);</span>
    
                <span class="o">}</span>
    
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">if</span> <span class="o">(!</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">if</span> <span class="o">(</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
        
                        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
                    
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
        
                        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">();</span>
        
                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;No value specified for the button&#39;s &quot;</span> <span class="o">+</span>
                            <span class="s2">&quot;\&quot;id\&quot; attribute. Setting button id to \&quot;&quot;</span> <span class="o">+</span> 
                            <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;\&quot;.&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">);</span>
        
                    <span class="o">}</span>
    
                <span class="o">}</span>
    
    
                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">LogWriter</span><span class="o">(</span>
                    <span class="s2">&quot;Button &quot;</span> <span class="o">+</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
    
                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Building the button using an existing HTML &quot;</span> <span class="o">+</span> 
                    <span class="s2">&quot;element as a source element.&quot;</span><span class="o">);</span>
    
    
                <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">srcelement</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">;</span>
        
                <span class="nx">initConfig</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">);</span>
        
        
                <span class="k">if</span> <span class="o">(!</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Source element could not be used as is.&quot;</span> <span class="o">+</span>
                            <span class="s2">&quot;  Creating a new HTML element for the button.&quot;</span><span class="o">);</span>
            
                    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span> <span class="o">=</span> 
                        <span class="k">this</span><span class="o">.</span><span class="nx">createButtonElement</span><span class="o">(</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">type</span><span class="o">);</span>
            
                <span class="o">}</span>
            
                <span class="nx">fnSuperClass</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">);</span>
            
            <span class="o">}</span>
    
        <span class="o">}</span>
    
    <span class="o">};</span>



    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">extend</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Element</span><span class="o">,</span> <span class="o">{</span>
    
    
        <span class="c">// Protected properties</span>
<span class="c"></span>        
        
        <span class="c">/** </span>
<span class="c">        * @property _button</span>
<span class="c">        * @description Object reference to the button&#39;s internal </span>
<span class="c">        * &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt; or &lt;code&gt;&amp;#60;button&amp;#62;&lt;/code&gt; element.</span>
<span class="c">        * @default null</span>
<span class="c">        * @protected</span>
<span class="c">        * @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">        * level-one-html.html#ID-48250443&quot;&gt;HTMLAnchorElement&lt;/a&gt;|&lt;a href=&quot;</span>
<span class="c">        * http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html</span>
<span class="c">        * #ID-34812697&quot;&gt;HTMLButtonElement&lt;/a&gt;</span>
<span class="c">        */</span>
        <span class="nx">_button</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        
        
        <span class="c">/** </span>
<span class="c">        * @property _menu</span>
<span class="c">        * @description Object reference to the button&#39;s menu.</span>
<span class="c">        * @default null</span>
<span class="c">        * @protected</span>
<span class="c">        * @type {&lt;a href=&quot;YAHOO.widget.Overlay.html&quot;&gt;YAHOO.widget.Overlay&lt;/a&gt;|</span>
<span class="c">        * &lt;a href=&quot;YAHOO.widget.Menu.html&quot;&gt;YAHOO.widget.Menu&lt;/a&gt;}</span>
<span class="c">        */</span>
        <span class="nx">_menu</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        
        
        <span class="c">/** </span>
<span class="c">        * @property _hiddenFields</span>
<span class="c">        * @description Object reference to the &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt;  </span>
<span class="c">        * element, or array of HTML form elements used to represent the button</span>
<span class="c">        *  when its parent form is submitted.</span>
<span class="c">        * @default null</span>
<span class="c">        * @protected</span>
<span class="c">        * @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">        * level-one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;|Array</span>
<span class="c">        */</span>
        <span class="nx">_hiddenFields</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        
        
        <span class="c">/** </span>
<span class="c">        * @property _onclickAttributeValue</span>
<span class="c">        * @description Object reference to the button&#39;s current value for the </span>
<span class="c">        * &quot;onclick&quot; configuration attribute.</span>
<span class="c">        * @default null</span>
<span class="c">        * @protected</span>
<span class="c">        * @type Object</span>
<span class="c">        */</span>
        <span class="nx">_onclickAttributeValue</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        
        
        <span class="c">/** </span>
<span class="c">        * @property _activationKeyPressed</span>
<span class="c">        * @description Boolean indicating if the key(s) that toggle the button&#39;s </span>
<span class="c">        * &quot;active&quot; state have been pressed.</span>
<span class="c">        * @default false</span>
<span class="c">        * @protected</span>
<span class="c">        * @type Boolean</span>
<span class="c">        */</span>
        <span class="nx">_activationKeyPressed</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
        
        
        <span class="c">/** </span>
<span class="c">        * @property _activationButtonPressed</span>
<span class="c">        * @description Boolean indicating if the mouse button that toggles </span>
<span class="c">        * the button&#39;s &quot;active&quot; state has been pressed.</span>
<span class="c">        * @default false</span>
<span class="c">        * @protected</span>
<span class="c">        * @type Boolean</span>
<span class="c">        */</span>
        <span class="nx">_activationButtonPressed</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
        
        
        <span class="c">/** </span>
<span class="c">        * @property _hasKeyEventHandlers</span>
<span class="c">        * @description Boolean indicating if the button&#39;s &quot;blur&quot;, &quot;keydown&quot; and </span>
<span class="c">        * &quot;keyup&quot; event handlers are assigned</span>
<span class="c">        * @default false</span>
<span class="c">        * @protected</span>
<span class="c">        * @type Boolean</span>
<span class="c">        */</span>
        <span class="nx">_hasKeyEventHandlers</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
        
        
        <span class="c">/** </span>
<span class="c">        * @property _hasMouseEventHandlers</span>
<span class="c">        * @description Boolean indicating if the button&#39;s &quot;mouseout,&quot; </span>
<span class="c">        * &quot;mousedown,&quot; and &quot;mouseup&quot; event handlers are assigned</span>
<span class="c">        * @default false</span>
<span class="c">        * @protected</span>
<span class="c">        * @type Boolean</span>
<span class="c">        */</span>
        <span class="nx">_hasMouseEventHandlers</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
        
        
        
        <span class="c">// Constants</span>
<span class="c"></span>        
        
        <span class="c">/**</span>
<span class="c">        * @property NODE_NAME</span>
<span class="c">        * @description The name of the node to be used for the button&#39;s </span>
<span class="c">        * root element.</span>
<span class="c">        * @default &quot;SPAN&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">NODE_NAME</span><span class="o">:</span> <span class="s2">&quot;SPAN&quot;</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property CHECK_ACTIVATION_KEYS</span>
<span class="c">        * @description Array of numbers representing keys that (when pressed) </span>
<span class="c">        * toggle the button&#39;s &quot;checked&quot; attribute.</span>
<span class="c">        * @default [32]</span>
<span class="c">        * @final</span>
<span class="c">        * @type Array</span>
<span class="c">        */</span>
        <span class="nx">CHECK_ACTIVATION_KEYS</span><span class="o">:</span> <span class="o">[</span><span class="m">32</span><span class="o">],</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property ACTIVATION_KEYS</span>
<span class="c">        * @description Array of numbers representing keys that (when presed) </span>
<span class="c">        * toggle the button&#39;s &quot;active&quot; state.</span>
<span class="c">        * @default [13, 32]</span>
<span class="c">        * @final</span>
<span class="c">        * @type Array</span>
<span class="c">        */</span>
        <span class="nx">ACTIVATION_KEYS</span><span class="o">:</span> <span class="o">[</span><span class="m">13</span><span class="o">,</span> <span class="m">32</span><span class="o">],</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property OPTION_AREA_WIDTH</span>
<span class="c">        * @description Width (in pixels) of the area of a split button that  </span>
<span class="c">        * when pressed will display a menu.</span>
<span class="c">        * @default 20</span>
<span class="c">        * @final</span>
<span class="c">        * @type Number</span>
<span class="c">        */</span>
        <span class="nx">OPTION_AREA_WIDTH</span><span class="o">:</span> <span class="m">20</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property CSS_CLASS_NAME</span>
<span class="c">        * @description String representing the CSS class(es) to be applied to  </span>
<span class="c">        * the button&#39;s root element.</span>
<span class="c">        * @default &quot;yui-button&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">CSS_CLASS_NAME</span><span class="o">:</span> <span class="s2">&quot;yui-button&quot;</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property RADIO_DEFAULT_TITLE</span>
<span class="c">        * @description String representing the default title applied to buttons </span>
<span class="c">        * of type &quot;radio.&quot; </span>
<span class="c">        * @default &quot;Unchecked.  Click to check.&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">RADIO_DEFAULT_TITLE</span><span class="o">:</span> <span class="s2">&quot;Unchecked.  Click to check.&quot;</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property RADIO_CHECKED_TITLE</span>
<span class="c">        * @description String representing the title applied to buttons of </span>
<span class="c">        * type &quot;radio&quot; when checked.</span>
<span class="c">        * @default &quot;Checked.  Click to uncheck.&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">RADIO_CHECKED_TITLE</span><span class="o">:</span> <span class="s2">&quot;Checked.  Click to uncheck.&quot;</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property CHECKBOX_DEFAULT_TITLE</span>
<span class="c">        * @description String representing the default title applied to </span>
<span class="c">        * buttons of type &quot;checkbox.&quot; </span>
<span class="c">        * @default &quot;Unchecked.  Click to check.&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">CHECKBOX_DEFAULT_TITLE</span><span class="o">:</span> <span class="s2">&quot;Unchecked.  Click to check.&quot;</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property CHECKBOX_CHECKED_TITLE</span>
<span class="c">        * @description String representing the title applied to buttons of type </span>
<span class="c">        * &quot;checkbox&quot; when checked.</span>
<span class="c">        * @default &quot;Checked.  Click to uncheck.&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">CHECKBOX_CHECKED_TITLE</span><span class="o">:</span> <span class="s2">&quot;Checked.  Click to uncheck.&quot;</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property MENUBUTTON_DEFAULT_TITLE</span>
<span class="c">        * @description String representing the default title applied to </span>
<span class="c">        * buttons of type &quot;menu.&quot; </span>
<span class="c">        * @default &quot;Menu collapsed.  Click to expand.&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">MENUBUTTON_DEFAULT_TITLE</span><span class="o">:</span> <span class="s2">&quot;Menu collapsed.  Click to expand.&quot;</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property MENUBUTTON_MENU_VISIBLE_TITLE</span>
<span class="c">        * @description String representing the title applied to buttons of type </span>
<span class="c">        * &quot;menu&quot; when the button&#39;s menu is visible. </span>
<span class="c">        * @default &quot;Menu expanded.  Click or press Esc to collapse.&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">MENUBUTTON_MENU_VISIBLE_TITLE</span><span class="o">:</span> 
            <span class="s2">&quot;Menu expanded.  Click or press Esc to collapse.&quot;</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property SPLITBUTTON_DEFAULT_TITLE</span>
<span class="c">        * @description  String representing the default title applied to </span>
<span class="c">        * buttons of type &quot;split.&quot; </span>
<span class="c">        * @default &quot;Menu collapsed.  Click inside option region or press </span>
<span class="c">        * Ctrl + Shift + M to show the menu.&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">SPLITBUTTON_DEFAULT_TITLE</span><span class="o">:</span> <span class="o">(</span><span class="s2">&quot;Menu collapsed.  Click inside option &quot;</span> <span class="o">+</span> 
            <span class="s2">&quot;region or press Ctrl + Shift + M to show the menu.&quot;</span><span class="o">),</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property SPLITBUTTON_OPTION_VISIBLE_TITLE</span>
<span class="c">        * @description String representing the title applied to buttons of type </span>
<span class="c">        * &quot;split&quot; when the button&#39;s menu is visible. </span>
<span class="c">        * @default &quot;Menu expanded.  Press Esc or Ctrl + Shift + M to hide </span>
<span class="c">        * the menu.&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">SPLITBUTTON_OPTION_VISIBLE_TITLE</span><span class="o">:</span> 
            <span class="s2">&quot;Menu expanded.  Press Esc or Ctrl + Shift + M to hide the menu.&quot;</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @property SUBMIT_TITLE</span>
<span class="c">        * @description String representing the title applied to buttons of </span>
<span class="c">        * type &quot;submit.&quot; </span>
<span class="c">        * @default &quot;Click to submit form.&quot;</span>
<span class="c">        * @final</span>
<span class="c">        * @type String</span>
<span class="c">        */</span>
        <span class="nx">SUBMIT_TITLE</span><span class="o">:</span> <span class="s2">&quot;Click to submit form.&quot;</span><span class="o">,</span>
        
        
        
        <span class="c">// Protected attribute setter methods</span>
<span class="c"></span>        
        
        <span class="c">/**</span>
<span class="c">        * @method _setType</span>
<span class="c">        * @description Sets the value of the button&#39;s &quot;type&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {String} p_sType String indicating the value for the button&#39;s </span>
<span class="c">        * &quot;type&quot; attribute.</span>
<span class="c">        */</span>
        <span class="nx">_setType</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">p_sType</span> <span class="o">==</span> <span class="s2">&quot;split&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onOption</span><span class="o">);</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _setLabel</span>
<span class="c">        * @description Sets the value of the button&#39;s &quot;label&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {String} p_sLabel String indicating the value for the button&#39;s </span>
<span class="c">        * &quot;label&quot; attribute.</span>
<span class="c">        */</span>
        <span class="nx">_setLabel</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sLabel</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">p_sLabel</span><span class="o">;</span>
            
            <span class="c">/*</span>
<span class="c">                Remove and add the default class name from the root element</span>
<span class="c">                for Gecko to ensure that the button shrinkwraps to the label.</span>
<span class="c">                Without this the button will not be rendered at the correct </span>
<span class="c">                width when the label changes.  The most likely cause for this </span>
<span class="c">                bug is button&#39;s use of the Gecko-specific CSS display type of </span>
<span class="c">                &quot;-moz-inline-box&quot; to simulate &quot;inline-block&quot; supported by IE, </span>
<span class="c">                Safari and Opera.</span>
<span class="c">            */</span>
            
            <span class="k">var</span> <span class="nx">sClass</span><span class="o">,</span>
                <span class="nx">me</span><span class="o">;</span>
            
            <span class="k">if</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">env</span><span class="o">.</span><span class="nx">ua</span><span class="o">.</span><span class="nx">gecko</span> <span class="o">&amp;&amp;</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">inDocument</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">)))</span> <span class="o">{</span>
            
                <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
                <span class="nx">sClass</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span><span class="o">;</span>                

                <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">sClass</span><span class="o">);</span>
                
                <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
                
                    <span class="nx">me</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">sClass</span><span class="o">);</span>
                
                <span class="o">},</span> <span class="m">0</span><span class="o">);</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _setTabIndex</span>
<span class="c">        * @description Sets the value of the button&#39;s &quot;tabindex&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Number} p_nTabIndex Number indicating the value for the </span>
<span class="c">        * button&#39;s &quot;tabindex&quot; attribute.</span>
<span class="c">        */</span>
        <span class="nx">_setTabIndex</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_nTabIndex</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">tabIndex</span> <span class="o">=</span> <span class="nx">p_nTabIndex</span><span class="o">;</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _setTitle</span>
<span class="c">        * @description Sets the value of the button&#39;s &quot;title&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {String} p_nTabIndex Number indicating the value for </span>
<span class="c">        * the button&#39;s &quot;title&quot; attribute.</span>
<span class="c">        */</span>
        <span class="nx">_setTitle</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sTitle</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sTitle</span> <span class="o">=</span> <span class="nx">p_sTitle</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;link&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(!</span><span class="nx">sTitle</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">switch</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">))</span> <span class="o">{</span>
        
                    <span class="nx">case</span> <span class="s2">&quot;radio&quot;</span><span class="o">:</span>
    
                        <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">RADIO_DEFAULT_TITLE</span><span class="o">;</span>
    
                        <span class="k">break</span><span class="o">;</span>
    
                    <span class="nx">case</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">:</span>
    
                        <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">CHECKBOX_DEFAULT_TITLE</span><span class="o">;</span>
    
                        <span class="k">break</span><span class="o">;</span>
                    
                    <span class="nx">case</span> <span class="s2">&quot;menu&quot;</span><span class="o">:</span>
    
                        <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">MENUBUTTON_DEFAULT_TITLE</span><span class="o">;</span>
    
                        <span class="k">break</span><span class="o">;</span>
    
                    <span class="nx">case</span> <span class="s2">&quot;split&quot;</span><span class="o">:</span>
    
                        <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">SPLITBUTTON_DEFAULT_TITLE</span><span class="o">;</span>
    
                        <span class="k">break</span><span class="o">;</span>
    
                    <span class="nx">case</span> <span class="s2">&quot;submit&quot;</span><span class="o">:</span>
    
                        <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">SUBMIT_TITLE</span><span class="o">;</span>
    
                        <span class="k">break</span><span class="o">;</span>
        
                    <span class="o">}</span>
        
                <span class="o">}</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">title</span> <span class="o">=</span> <span class="nx">sTitle</span><span class="o">;</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _setDisabled</span>
<span class="c">        * @description Sets the value of the button&#39;s &quot;disabled&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Boolean} p_bDisabled Boolean indicating the value for </span>
<span class="c">        * the button&#39;s &quot;disabled&quot; attribute.</span>
<span class="c">        */</span>
        <span class="nx">_setDisabled</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_bDisabled</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;link&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">p_bDisabled</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">)</span> <span class="o">{</span>
        
                        <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
        
                    <span class="o">}</span>
        
                    <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">hasFocus</span><span class="o">())</span> <span class="o">{</span>
                    
                        <span class="k">this</span><span class="o">.</span><span class="nx">blur</span><span class="o">();</span>
                    
                    <span class="o">}</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">,</span> <span class="s2">&quot;disabled&quot;</span><span class="o">);</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">);</span>

                    <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;hover&quot;</span><span class="o">);</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;focus&quot;</span><span class="o">);</span>
        
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">removeAttribute</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">);</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">);</span>
                
                <span class="o">}</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>

        
        <span class="c">/**</span>
<span class="c">        * @method _setHref</span>
<span class="c">        * @description Sets the value of the button&#39;s &quot;href&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {String} p_sHref String indicating the value for the button&#39;s </span>
<span class="c">        * &quot;href&quot; attribute.</span>
<span class="c">        */</span>
        <span class="nx">_setHref</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sHref</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;link&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">href</span> <span class="o">=</span> <span class="nx">p_sHref</span><span class="o">;</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _setTarget</span>
<span class="c">        * @description Sets the value of the button&#39;s &quot;target&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {String} p_sTarget String indicating the value for the button&#39;s </span>
<span class="c">        * &quot;target&quot; attribute.</span>
<span class="c">        */</span>
        <span class="nx">_setTarget</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sTarget</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;link&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;target&quot;</span><span class="o">,</span> <span class="nx">p_sTarget</span><span class="o">);</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _setChecked</span>
<span class="c">        * @description Sets the value of the button&#39;s &quot;target&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Boolean} p_bChecked Boolean indicating the value for  </span>
<span class="c">        * the button&#39;s &quot;checked&quot; attribute.</span>
<span class="c">        */</span>
        <span class="nx">_setChecked</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_bChecked</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">),</span>
                <span class="nx">sTitle</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">p_bChecked</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">);</span>
                    
                    <span class="nx">sTitle</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">?</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">RADIO_CHECKED_TITLE</span> <span class="o">:</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">CHECKBOX_CHECKED_TITLE</span><span class="o">;</span>
                
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>

                    <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">);</span>
        
                    <span class="nx">sTitle</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">?</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">RADIO_DEFAULT_TITLE</span> <span class="o">:</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">CHECKBOX_DEFAULT_TITLE</span><span class="o">;</span>
                
                <span class="o">}</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _setMenu</span>
<span class="c">        * @description Sets the value of the button&#39;s &quot;menu&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Object} p_oMenu Object indicating the value for the button&#39;s </span>
<span class="c">        * &quot;menu&quot; attribute.</span>
<span class="c">        */</span>
        <span class="nx">_setMenu</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">bLazyLoad</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;lazyloadmenu&quot;</span><span class="o">),</span>
                <span class="nx">oButtonElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">),</span>
                <span class="nx">sMenuCSSClassName</span> <span class="o">=</span> <span class="nx">Menu</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span><span class="o">,</span>
        
                <span class="c">/*</span>
<span class="c">                    Boolean indicating if the value of p_oMenu is an instance </span>
<span class="c">                    of YAHOO.widget.Menu or YAHOO.widget.Overlay.</span>
<span class="c">                */</span>
        
                <span class="nx">bInstance</span> <span class="o">=</span> <span class="kc">false</span><span class="o">,</span>
        

                <span class="nx">oMenu</span><span class="o">,</span>
                <span class="nx">oMenuElement</span><span class="o">,</span>
                <span class="nx">oSrcElement</span><span class="o">,</span>
                <span class="nx">aItems</span><span class="o">,</span>
                <span class="nx">nItems</span><span class="o">,</span>
                <span class="nx">oItem</span><span class="o">,</span>
                <span class="nx">i</span><span class="o">;</span>
        
        
            <span class="k">if</span> <span class="o">(!</span><span class="nx">Overlay</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;YAHOO.widget.Overlay dependency not met.&quot;</span><span class="o">,</span> 
                    <span class="s2">&quot;error&quot;</span><span class="o">);</span>
        
                <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
            
            <span class="o">}</span>
        
        
            <span class="k">if</span> <span class="o">(!</span><span class="nx">Menu</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;YAHOO.widget.Menu dependency not met.&quot;</span><span class="o">,</span> 
                    <span class="s2">&quot;error&quot;</span><span class="o">);</span>
        
                <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
            
            <span class="o">}</span>
        
        
            <span class="k">function</span> <span class="nx">onAppendTo</span><span class="o">()</span> <span class="o">{</span>

                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">render</span><span class="o">(</span><span class="nx">oButtonElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">);</span>
                
                <span class="k">this</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="s2">&quot;appendTo&quot;</span><span class="o">,</span> <span class="nx">onAppendTo</span><span class="o">);</span>
            
            <span class="o">}</span>
        
        
            <span class="k">function</span> <span class="nx">initMenu</span><span class="o">()</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span><span class="o">)</span> <span class="o">{</span>

                    <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oMenu</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;menuclassname&quot;</span><span class="o">));</span>
                    <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oMenu</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> 
                            <span class="s2">&quot;yui-&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot;-button-menu&quot;</span><span class="o">);</span>

                    <span class="nx">oMenu</span><span class="o">.</span><span class="nx">showEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuShow</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
                    <span class="nx">oMenu</span><span class="o">.</span><span class="nx">hideEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuHide</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
                    <span class="nx">oMenu</span><span class="o">.</span><span class="nx">renderEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuRender</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        
        
                    <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="k">instanceof</span> <span class="nx">Menu</span><span class="o">)</span> <span class="o">{</span>
        
                        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">keyDownEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuKeyDown</span><span class="o">,</span> 
                            <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

                        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMenuClick</span><span class="o">,</span> 
                            <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

                        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">itemAddedEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuItemAdded</span><span class="o">,</span> 
                            <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        
                        <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">;</span>
        
                        <span class="k">if</span> <span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> 
                            <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">)</span> <span class="o">{</span>
                
                            <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>
                            <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oSrcElement</span><span class="o">);</span>
        
                        <span class="o">}</span>
        
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="k">instanceof</span> <span class="nx">Overlay</span><span class="o">)</span> <span class="o">{</span>
        
                        <span class="k">if</span> <span class="o">(!</span><span class="nx">m_oOverlayManager</span><span class="o">)</span> <span class="o">{</span>
        
                            <span class="nx">m_oOverlayManager</span> <span class="o">=</span> 
                                <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">OverlayManager</span><span class="o">();</span>
                        
                        <span class="o">}</span>
                        
                        <span class="nx">m_oOverlayManager</span><span class="o">.</span><span class="nx">register</span><span class="o">(</span><span class="nx">oMenu</span><span class="o">);</span>
                        
                    <span class="o">}</span>
        
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">;</span>

        
                    <span class="k">if</span> <span class="o">(!</span><span class="nx">bInstance</span><span class="o">)</span> <span class="o">{</span>
        
                        <span class="k">if</span> <span class="o">(</span><span class="nx">bLazyLoad</span> <span class="o">&amp;&amp;</span> <span class="o">!(</span><span class="nx">oMenu</span> <span class="k">instanceof</span> <span class="nx">Menu</span><span class="o">))</span> <span class="o">{</span>
        
                            <span class="c">/*</span>
<span class="c">                                Mimic Menu&#39;s &quot;lazyload&quot; functionality by adding  </span>
<span class="c">                                a &quot;beforeshow&quot; event listener that renders the </span>
<span class="c">                                Overlay instance before it is made visible by  </span>
<span class="c">                                the button.</span>
<span class="c">                            */</span>
        
                            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">beforeShowEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">_onOverlayBeforeShow</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
            
                        <span class="o">}</span>
                        <span class="k">else</span> <span class="k">if</span> <span class="o">(!</span><span class="nx">bLazyLoad</span><span class="o">)</span> <span class="o">{</span>
        
                            <span class="k">if</span> <span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">inDocument</span><span class="o">(</span><span class="nx">oButtonElement</span><span class="o">))</span> <span class="o">{</span>
        
                                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">render</span><span class="o">(</span><span class="nx">oButtonElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">);</span>
                            
                            <span class="o">}</span>
                            <span class="k">else</span> <span class="o">{</span>
            
                                <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;appendTo&quot;</span><span class="o">,</span> <span class="nx">onAppendTo</span><span class="o">);</span>
                            
                            <span class="o">}</span>
                        
                        <span class="o">}</span>
                    
                    <span class="o">}</span>
        
                <span class="o">}</span>
        
            <span class="o">}</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">p_oMenu</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">p_oMenu</span> <span class="k">instanceof</span> <span class="nx">Menu</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="nx">oMenu</span> <span class="o">=</span> <span class="nx">p_oMenu</span><span class="o">;</span>
                <span class="nx">aItems</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">getItems</span><span class="o">();</span>
                <span class="nx">nItems</span> <span class="o">=</span> <span class="nx">aItems</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
                <span class="nx">bInstance</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">nItems</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">i</span> <span class="o">=</span> <span class="nx">nItems</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
        
                    <span class="k">do</span> <span class="o">{</span>
        
                        <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">aItems</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
        
                        <span class="k">if</span> <span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>
        
                            <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">subscribeToConfigEvent</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">_onMenuItemSelected</span><span class="o">,</span> 
                                <span class="nx">oItem</span><span class="o">,</span> 
                                <span class="k">this</span><span class="o">);</span>
        
                        <span class="o">}</span>
        
                    <span class="o">}</span>
                    <span class="k">while</span> <span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
        
                <span class="o">}</span>
        
                <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">p_oMenu</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">p_oMenu</span> <span class="k">instanceof</span> <span class="nx">Overlay</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="nx">oMenu</span> <span class="o">=</span> <span class="nx">p_oMenu</span><span class="o">;</span>
                <span class="nx">bInstance</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>
                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;context&quot;</span><span class="o">,</span> <span class="o">[</span><span class="nx">oButtonElement</span><span class="o">,</span> <span class="s2">&quot;tl&quot;</span><span class="o">,</span> <span class="s2">&quot;bl&quot;</span><span class="o">]);</span>
        
                <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;appendTo&quot;</span><span class="o">,</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
                    <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Menu</span><span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">(),</span> <span class="o">{</span> <span class="nx">lazyload</span><span class="o">:</span> <span class="nx">bLazyLoad</span><span class="o">,</span> 
                        <span class="nx">itemdata</span><span class="o">:</span> <span class="nx">p_oMenu</span> <span class="o">});</span>
        
                    <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
        
                <span class="o">});</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="nx">oMenuElement</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">);</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">oMenuElement</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">if</span> <span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">oMenuElement</span><span class="o">,</span> <span class="nx">sMenuCSSClassName</span><span class="o">)</span> <span class="o">||</span> 
                        <span class="nx">oMenuElement</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">)</span> <span class="o">{</span>
            
                        <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Menu</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">,</span> <span class="o">{</span> <span class="nx">lazyload</span><span class="o">:</span> <span class="nx">bLazyLoad</span> <span class="o">});</span>
            
                        <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
            
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
        
                        <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Overlay</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">,</span> <span class="o">{</span> <span class="nx">visible</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span> 
                            <span class="nx">context</span><span class="o">:</span> <span class="o">[</span><span class="nx">oButtonElement</span><span class="o">,</span> <span class="s2">&quot;tl&quot;</span><span class="o">,</span> <span class="s2">&quot;bl&quot;</span><span class="o">]</span> <span class="o">});</span>
            
                        <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
            
                    <span class="o">}</span>
        
                <span class="o">}</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">p_oMenu</span> <span class="o">&amp;&amp;</span> <span class="nx">p_oMenu</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">,</span> <span class="nx">sMenuCSSClassName</span><span class="o">)</span> <span class="o">||</span> 
                        <span class="nx">p_oMenu</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Menu</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">,</span> <span class="o">{</span> <span class="nx">lazyload</span><span class="o">:</span> <span class="nx">bLazyLoad</span> <span class="o">});</span>
                
                    <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
        
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
        
                    <span class="k">if</span> <span class="o">(!</span><span class="nx">p_oMenu</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
                    
                        <span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">);</span>
                    
                    <span class="o">}</span>
        
                    <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Overlay</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">,</span> <span class="o">{</span> <span class="nx">visible</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span> 
                                    <span class="nx">context</span><span class="o">:</span> <span class="o">[</span><span class="nx">oButtonElement</span><span class="o">,</span> <span class="s2">&quot;tl&quot;</span><span class="o">,</span> <span class="s2">&quot;bl&quot;</span><span class="o">]</span> <span class="o">});</span>
        
                    <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
                
                <span class="o">}</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _setOnClick</span>
<span class="c">        * @description Sets the value of the button&#39;s &quot;onclick&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Object} p_oObject Object indicating the value for the button&#39;s </span>
<span class="c">        * &quot;onclick&quot; attribute.</span>
<span class="c">        */</span>
        <span class="nx">_setOnClick</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oObject</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="c">/*</span>
<span class="c">                Remove any existing listeners if a &quot;click&quot; event handler </span>
<span class="c">                has already been specified.</span>
<span class="c">            */</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span> <span class="o">&amp;&amp;</span> 
                <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span> <span class="o">!=</span> <span class="nx">p_oObject</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span><span class="o">.</span><span class="nx">fn</span><span class="o">);</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        
            <span class="o">}</span>
        
        
            <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span> <span class="o">&amp;&amp;</span> 
                <span class="nx">Lang</span><span class="o">.</span><span class="nx">isObject</span><span class="o">(</span><span class="nx">p_oObject</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
                <span class="nx">Lang</span><span class="o">.</span><span class="nx">isFunction</span><span class="o">(</span><span class="nx">p_oObject</span><span class="o">.</span><span class="nx">fn</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="nx">p_oObject</span><span class="o">.</span><span class="nx">fn</span><span class="o">,</span> <span class="nx">p_oObject</span><span class="o">.</span><span class="nx">obj</span><span class="o">,</span> <span class="nx">p_oObject</span><span class="o">.</span><span class="nx">scope</span><span class="o">);</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span> <span class="o">=</span> <span class="nx">p_oObject</span><span class="o">;</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _setSelectedMenuItem</span>
<span class="c">        * @description Sets the value of the button&#39;s </span>
<span class="c">        * &quot;selectedMenuItem&quot; attribute.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Number} p_nIndex Number representing the index of the item </span>
<span class="c">        * in the button&#39;s menu that is currently selected.</span>
<span class="c">        */</span>
        <span class="nx">_setSelectedMenuItem</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_nIndex</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">,</span>
                <span class="nx">oMenuItem</span><span class="o">;</span>


            <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="o">&amp;&amp;</span> <span class="nx">oMenu</span> <span class="k">instanceof</span> <span class="nx">Menu</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oMenuItem</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">getItem</span><span class="o">(</span><span class="nx">p_nIndex</span><span class="o">);</span>
                

                <span class="k">if</span> <span class="o">(</span><span class="nx">oMenuItem</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">))</span> <span class="o">{</span>
                
                    <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
                
                <span class="o">}</span>
            
            <span class="o">}</span>

        <span class="o">},</span>
        
        
        <span class="c">// Protected methods</span>
<span class="c"></span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _isActivationKey</span>
<span class="c">        * @description Determines if the specified keycode is one that toggles  </span>
<span class="c">        * the button&#39;s &quot;active&quot; state.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Number} p_nKeyCode Number representing the keycode to </span>
<span class="c">        * be evaluated.</span>
<span class="c">        * @return {Boolean}</span>
<span class="c">        */</span>
        <span class="nx">_isActivationKey</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_nKeyCode</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">),</span>
                <span class="nx">aKeyCodes</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">?</span> 
                    <span class="k">this</span><span class="o">.</span><span class="nx">CHECK_ACTIVATION_KEYS</span> <span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">ACTIVATION_KEYS</span><span class="o">,</span>
        
                <span class="nx">nKeyCodes</span> <span class="o">=</span> <span class="nx">aKeyCodes</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
                <span class="nx">i</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">nKeyCodes</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">i</span> <span class="o">=</span> <span class="nx">nKeyCodes</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
        
                <span class="k">do</span> <span class="o">{</span>
        
                    <span class="k">if</span> <span class="o">(</span><span class="nx">p_nKeyCode</span> <span class="o">==</span> <span class="nx">aKeyCodes</span><span class="o">[</span><span class="nx">i</span><span class="o">])</span> <span class="o">{</span>
        
                        <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
        
                    <span class="o">}</span>
        
                <span class="o">}</span>
                <span class="k">while</span> <span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _isSplitButtonOptionKey</span>
<span class="c">        * @description Determines if the specified keycode is one that toggles  </span>
<span class="c">        * the display of the split button&#39;s menu.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        * @return {Boolean}</span>
<span class="c">        */</span>
        <span class="nx">_isSplitButtonOptionKey</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">return</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">ctrlKey</span> <span class="o">&amp;&amp;</span> <span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">shiftKey</span> <span class="o">&amp;&amp;</span> 
                <span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">==</span> <span class="m">77</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _addListenersToForm</span>
<span class="c">        * @description Adds event handlers to the button&#39;s form.</span>
<span class="c">        * @protected</span>
<span class="c">        */</span>
        <span class="nx">_addListenersToForm</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">(),</span>
                <span class="nx">onFormKeyPress</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">onFormKeyPress</span><span class="o">,</span>
                <span class="nx">bHasKeyPressListener</span><span class="o">,</span>
                <span class="nx">oSrcElement</span><span class="o">,</span>
                <span class="nx">aListeners</span><span class="o">,</span>
                <span class="nx">nListeners</span><span class="o">,</span>
                <span class="nx">i</span><span class="o">;</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;reset&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFormReset</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
                <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;submit&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">createHiddenFields</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        
                <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">);</span>
        
        
                <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span> <span class="o">||</span> 
                    <span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span><span class="o">))</span> 
                <span class="o">{</span>
                
                    <span class="nx">aListeners</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getListeners</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;keypress&quot;</span><span class="o">);</span>
                    <span class="nx">bHasKeyPressListener</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
            
                    <span class="k">if</span> <span class="o">(</span><span class="nx">aListeners</span><span class="o">)</span> <span class="o">{</span>
            
                        <span class="nx">nListeners</span> <span class="o">=</span> <span class="nx">aListeners</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
        
                        <span class="k">if</span> <span class="o">(</span><span class="nx">nListeners</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
            
                            <span class="nx">i</span> <span class="o">=</span> <span class="nx">nListeners</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
                            
                            <span class="k">do</span> <span class="o">{</span>
               
                                <span class="k">if</span> <span class="o">(</span><span class="nx">aListeners</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">fn</span> <span class="o">==</span> <span class="nx">onFormKeyPress</span><span class="o">)</span> <span class="o">{</span>
                
                                    <span class="nx">bHasKeyPressListener</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                                    <span class="k">break</span><span class="o">;</span>
                                
                                <span class="o">}</span>
                
                            <span class="o">}</span>
                            <span class="k">while</span> <span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
                        
                        <span class="o">}</span>
                    
                    <span class="o">}</span>
            
            
                    <span class="k">if</span> <span class="o">(!</span><span class="nx">bHasKeyPressListener</span><span class="o">)</span> <span class="o">{</span>
               
                        <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;keypress&quot;</span><span class="o">,</span> <span class="nx">onFormKeyPress</span><span class="o">);</span>
            
                    <span class="o">}</span>
        
                <span class="o">}</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="nx">_originalMaxHeight</span><span class="o">:</span> <span class="o">-</span><span class="m">1</span><span class="o">,</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _showMenu</span>
<span class="c">        * @description Shows the button&#39;s menu.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event) that triggered </span>
<span class="c">        * the display of the menu.</span>
<span class="c">        */</span>
        <span class="nx">_showMenu</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuManager</span><span class="o">.</span><span class="nx">hideVisible</span><span class="o">();</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">m_oOverlayManager</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">m_oOverlayManager</span><span class="o">.</span><span class="nx">hideAll</span><span class="o">();</span>
            
            <span class="o">}</span>
        
        
            <span class="k">var</span> <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">,</span>
                <span class="nx">nViewportHeight</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getViewportHeight</span><span class="o">(),</span>
                <span class="nx">nMenuHeight</span><span class="o">,</span>
                <span class="nx">nScrollTop</span><span class="o">,</span>
                <span class="nx">nY</span><span class="o">;</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="k">instanceof</span> <span class="nx">Menu</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">applyConfig</span><span class="o">({</span> <span class="nx">context</span><span class="o">:</span> <span class="o">[</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;id&quot;</span><span class="o">),</span> <span class="s2">&quot;tl&quot;</span><span class="o">,</span> <span class="s2">&quot;bl&quot;</span><span class="o">],</span>
                    <span class="nx">constraintoviewport</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
                    <span class="nx">clicktohide</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
                    <span class="nx">visible</span><span class="o">:</span> <span class="kc">true</span> <span class="o">});</span>
                    
                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">fireQueue</span><span class="o">();</span>
            
                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">align</span><span class="o">(</span><span class="s2">&quot;tl&quot;</span><span class="o">,</span> <span class="s2">&quot;bl&quot;</span><span class="o">);</span>
        
                <span class="c">/*</span>
<span class="c">                    Stop the propagation of the event so that the MenuManager </span>
<span class="c">                    doesn&#39;t blur the menu after it gets focus.</span>
<span class="c">                */</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">Event</span><span class="o">.</span><span class="nx">stopPropagation</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>
        
                <span class="o">}</span>


                <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;focusmenu&quot;</span><span class="o">))</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
                
                <span class="o">}</span>
        
                <span class="nx">nMenuHeight</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">offsetHeight</span><span class="o">;</span>
        
        
                <span class="k">if</span> <span class="o">((</span><span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;y&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="nx">nMenuHeight</span><span class="o">)</span> <span class="o">&gt;</span> 
                    <span class="nx">nViewportHeight</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Current menu position will place a &quot;</span> <span class="o">+</span> 
                        <span class="s2">&quot;portion, or the entire menu outside the boundary of &quot;</span> <span class="o">+</span>
                        <span class="s2">&quot;the viewport.  Repositioning the menu to stay &quot;</span> <span class="o">+</span>
                        <span class="s2">&quot;inside the viewport.&quot;</span><span class="o">);</span>
        
                    <span class="nx">oMenu</span><span class="o">.</span><span class="nx">align</span><span class="o">(</span><span class="s2">&quot;bl&quot;</span><span class="o">,</span> <span class="s2">&quot;tl&quot;</span><span class="o">);</span>
        
                    <span class="nx">nY</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;y&quot;</span><span class="o">);</span>
        
                    <span class="nx">nScrollTop</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getDocumentScrollTop</span><span class="o">();</span>
        
        
                    <span class="k">if</span> <span class="o">(</span><span class="nx">nScrollTop</span> <span class="o">&gt;=</span> <span class="nx">nY</span><span class="o">)</span> <span class="o">{</span>
        
                        <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_originalMaxHeight</span> <span class="o">==</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
        
                            <span class="k">this</span><span class="o">.</span><span class="nx">_originalMaxHeight</span> <span class="o">=</span> 
                                    <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">);</span>
        
                        <span class="o">}</span>
        
                        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">,</span> 
                                    <span class="o">(</span><span class="nx">nMenuHeight</span> <span class="o">-</span> <span class="o">((</span><span class="nx">nScrollTop</span> <span class="o">-</span> <span class="nx">nY</span><span class="o">)</span> <span class="o">+</span> <span class="m">20</span><span class="o">)));</span>
        
                        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">align</span><span class="o">(</span><span class="s2">&quot;bl&quot;</span><span class="o">,</span> <span class="s2">&quot;tl&quot;</span><span class="o">);</span>
        
                    <span class="o">}</span>
        
                <span class="o">}</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="k">instanceof</span> <span class="nx">Overlay</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">show</span><span class="o">();</span>
                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">align</span><span class="o">(</span><span class="s2">&quot;tl&quot;</span><span class="o">,</span> <span class="s2">&quot;bl&quot;</span><span class="o">);</span>

                <span class="nx">nMenuHeight</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">offsetHeight</span><span class="o">;</span>
        
        
                <span class="k">if</span> <span class="o">((</span><span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;y&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="nx">nMenuHeight</span><span class="o">)</span> <span class="o">&gt;</span> 
                    <span class="nx">nViewportHeight</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Current menu position will place a &quot;</span> <span class="o">+</span>
                        <span class="s2">&quot;portion, or the entire menu outside the boundary of &quot;</span> <span class="o">+</span> 
                        <span class="s2">&quot;the viewport.  Repositioning the menu to stay inside&quot;</span> <span class="o">+</span> 
                        <span class="s2">&quot; the viewport.&quot;</span><span class="o">);</span>
        
                    <span class="nx">oMenu</span><span class="o">.</span><span class="nx">align</span><span class="o">(</span><span class="s2">&quot;bl&quot;</span><span class="o">,</span> <span class="s2">&quot;tl&quot;</span><span class="o">);</span>
                    
                <span class="o">}</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _hideMenu</span>
<span class="c">        * @description Hides the button&#39;s menu.</span>
<span class="c">        * @protected</span>
<span class="c">        */</span>
        <span class="nx">_hideMenu</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        
        
        <span class="c">// Protected event handlers</span>
<span class="c"></span>        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMouseOver</span>
<span class="c">        * @description &quot;mouseover&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onMouseOver</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_hasMouseEventHandlers</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;mouseout&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseOut</span><span class="o">);</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseDown</span><span class="o">);</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseUp</span><span class="o">);</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_hasMouseEventHandlers</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
            <span class="o">}</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;hover&quot;</span><span class="o">);</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
        
            <span class="o">}</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;activeoption&quot;</span><span class="o">);</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMouseOut</span>
<span class="c">        * @description &quot;mouseout&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onMouseOut</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;hover&quot;</span><span class="o">);</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;menu&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
        
            <span class="o">}</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseUp</span><span class="o">,</span> 
                    <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        
            <span class="o">}</span>
            
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onDocumentMouseUp</span>
<span class="c">        * @description &quot;mouseup&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onDocumentMouseUp</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        
            <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;menu&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;split&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span>
                    <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;menu&quot;</span> <span class="o">?</span> <span class="s2">&quot;active&quot;</span> <span class="o">:</span> <span class="s2">&quot;activeoption&quot;</span><span class="o">));</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>
        
            <span class="o">}</span>
        
            <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseUp</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMouseDown</span>
<span class="c">        * @description &quot;mousedown&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onMouseDown</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sType</span><span class="o">,</span>
                <span class="nx">oElement</span><span class="o">,</span>
                <span class="nx">nX</span><span class="o">,</span>
                <span class="nx">me</span><span class="o">;</span>
        
        
            <span class="k">function</span> <span class="nx">onMouseUp</span><span class="o">()</span> <span class="o">{</span>
            
                <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="nx">onMouseUp</span><span class="o">);</span>
            
            <span class="o">}</span>
        
        
            <span class="k">if</span> <span class="o">((</span><span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">which</span> <span class="o">||</span> <span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">button</span><span class="o">)</span> <span class="o">==</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>
        
        
                <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">hasFocus</span><span class="o">())</span> <span class="o">{</span>
                
                    <span class="k">this</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
                
                <span class="o">}</span>
        
        
                <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>
        
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;split&quot;</span><span class="o">)</span> <span class="o">{</span>
                
                    <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">);</span>
                    <span class="nx">nX</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getPageX</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">-</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getX</span><span class="o">(</span><span class="nx">oElement</span><span class="o">);</span>
        
                    <span class="k">if</span> <span class="o">((</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">offsetWidth</span> <span class="o">-</span> <span class="k">this</span><span class="o">.</span><span class="nx">OPTION_AREA_WIDTH</span><span class="o">)</span> <span class="o">&lt;</span> <span class="nx">nX</span><span class="o">)</span> <span class="o">{</span>
                        
                        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">,</span> <span class="nx">p_oEvent</span><span class="o">);</span>
        
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
        
                        <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
        
                        <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
                    <span class="o">}</span>
        
                <span class="o">}</span>
                <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;menu&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isActive</span><span class="o">())</span> <span class="o">{</span>
        
                        <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>
        
                        <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
        
                        <span class="k">this</span><span class="o">.</span><span class="nx">_showMenu</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>
        
                        <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    
                    <span class="o">}</span>
        
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                
                <span class="o">}</span>
        
        
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;split&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;menu&quot;</span><span class="o">)</span> <span class="o">{</span>

                    <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenuTimerId</span> <span class="o">=</span> <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
                    
                        <span class="nx">me</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="nx">onMouseUp</span><span class="o">);</span>
                    
                    <span class="o">},</span> <span class="m">250</span><span class="o">);</span>
        
                <span class="o">}</span>
        
            <span class="o">}</span>
            
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMouseUp</span>
<span class="c">        * @description &quot;mouseup&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onMouseUp</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_hideMenuTimerId</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nb">window</span><span class="o">.</span><span class="nx">clearTimeout</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_hideMenuTimerId</span><span class="o">);</span>
        
            <span class="o">}</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">,</span> <span class="o">!(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">)));</span>
            
            <span class="o">}</span>
        
        
            <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
            
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;menu&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
            
            <span class="o">}</span>
            
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onFocus</span>
<span class="c">        * @description &quot;focus&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onFocus</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oElement</span><span class="o">;</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;focus&quot;</span><span class="o">);</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_activationKeyPressed</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
           
            <span class="o">}</span>
        
            <span class="nx">m_oFocusedButton</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
        
        
            <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_hasKeyEventHandlers</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">;</span>
        
                <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oElement</span><span class="o">,</span> <span class="s2">&quot;blur&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onBlur</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
                <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oElement</span><span class="o">,</span> <span class="s2">&quot;keydown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onKeyDown</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
                <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oElement</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onKeyUp</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_hasKeyEventHandlers</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
            <span class="o">}</span>
        
        
            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;focus&quot;</span><span class="o">,</span> <span class="nx">p_oEvent</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onBlur</span>
<span class="c">        * @description &quot;blur&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onBlur</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;focus&quot;</span><span class="o">);</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;menu&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>

            <span class="o">}</span>    
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_activationKeyPressed</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentKeyUp</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        
            <span class="o">}</span>
        
        
            <span class="nx">m_oFocusedButton</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;blur&quot;</span><span class="o">,</span> <span class="nx">p_oEvent</span><span class="o">);</span>
           
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onDocumentKeyUp</span>
<span class="c">        * @description &quot;keyup&quot; event handler for the document.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onDocumentKeyUp</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isActivationKey</span><span class="o">(</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_activationKeyPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
                
                <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentKeyUp</span><span class="o">);</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onKeyDown</span>
<span class="c">        * @description &quot;keydown&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onKeyDown</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;split&quot;</span> <span class="o">&amp;&amp;</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">_isSplitButtonOptionKey</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">,</span> <span class="nx">p_oEvent</span><span class="o">);</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isActivationKey</span><span class="o">(</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)))</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;menu&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_showMenu</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>
        
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_activationKeyPressed</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    
                    <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
                
                <span class="o">}</span>
            
            <span class="o">}</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="o">&amp;&amp;</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
                <span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">==</span> <span class="m">27</span><span class="o">)</span> <span class="o">{</span>
            
                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onKeyUp</span>
<span class="c">        * @description &quot;keyup&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onKeyUp</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sType</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isActivationKey</span><span class="o">(</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)))</span> <span class="o">{</span>
        
                <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">,</span> <span class="o">!(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">)));</span>
                
                <span class="o">}</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_activationKeyPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;menu&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
        
                <span class="o">}</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onClick</span>
<span class="c">        * @description &quot;click&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onClick</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">),</span>
                <span class="nx">sTitle</span><span class="o">,</span>
                <span class="nx">oForm</span><span class="o">,</span>
                <span class="nx">oSrcElement</span><span class="o">,</span>
                <span class="nx">oElement</span><span class="o">,</span>
                <span class="nx">nX</span><span class="o">;</span>
        
        
            <span class="nx">switch</span> <span class="o">(</span><span class="nx">sType</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="nx">case</span> <span class="s2">&quot;radio&quot;</span><span class="o">:</span>
            <span class="nx">case</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">:</span>
    
                <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">))</span> <span class="o">{</span>
                    
                    <span class="nx">sTitle</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">?</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">RADIO_CHECKED_TITLE</span> <span class="o">:</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">CHECKBOX_CHECKED_TITLE</span><span class="o">;</span>
                
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                
                    <span class="nx">sTitle</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">?</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">RADIO_DEFAULT_TITLE</span> <span class="o">:</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">CHECKBOX_DEFAULT_TITLE</span><span class="o">;</span>
                
                <span class="o">}</span>
                
                <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>
    
                <span class="k">break</span><span class="o">;</span>
    
            <span class="nx">case</span> <span class="s2">&quot;submit&quot;</span><span class="o">:</span>
    
                <span class="k">this</span><span class="o">.</span><span class="nx">submitForm</span><span class="o">();</span>
            
                <span class="k">break</span><span class="o">;</span>
    
            <span class="nx">case</span> <span class="s2">&quot;reset&quot;</span><span class="o">:</span>
    
                <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">();</span>
    
                <span class="k">if</span> <span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="nx">oForm</span><span class="o">.</span><span class="nx">reset</span><span class="o">();</span>
                
                <span class="o">}</span>
    
                <span class="k">break</span><span class="o">;</span>
    
            <span class="nx">case</span> <span class="s2">&quot;menu&quot;</span><span class="o">:</span>
    
                <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">)</span> <span class="o">?</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">MENUBUTTON_MENU_VISIBLE_TITLE</span> <span class="o">:</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">MENUBUTTON_DEFAULT_TITLE</span><span class="o">;</span>
    
                <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>
    
                <span class="k">break</span><span class="o">;</span>
    
            <span class="nx">case</span> <span class="s2">&quot;split&quot;</span><span class="o">:</span>
    
                <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">);</span>
                <span class="nx">nX</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getPageX</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">-</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getX</span><span class="o">(</span><span class="nx">oElement</span><span class="o">);</span>
    
                <span class="k">if</span> <span class="o">((</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">offsetWidth</span> <span class="o">-</span> <span class="k">this</span><span class="o">.</span><span class="nx">OPTION_AREA_WIDTH</span><span class="o">)</span> <span class="o">&lt;</span> <span class="nx">nX</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
                
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
    
                    <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>
        
                    <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">);</span>
        
                    <span class="k">if</span> <span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span><span class="o">)</span> <span class="o">{</span>
    
                        <span class="k">this</span><span class="o">.</span><span class="nx">submitForm</span><span class="o">();</span>
                    
                    <span class="o">}</span>
                
                <span class="o">}</span>
    
                <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">)</span> <span class="o">?</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">SPLITBUTTON_OPTION_VISIBLE_TITLE</span> <span class="o">:</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">SPLITBUTTON_DEFAULT_TITLE</span><span class="o">;</span>
    
                <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>
    
                <span class="k">break</span><span class="o">;</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onAppendTo</span>
<span class="c">        * @description &quot;appendTo&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onAppendTo</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="c">/*</span>
<span class="c">                It is necessary to call &quot;_addListenersToForm&quot; using </span>
<span class="c">                &quot;setTimeout&quot; to make sure that the button&#39;s &quot;form&quot; property </span>
<span class="c">                returns a node reference.  Sometimes, if you try to get the </span>
<span class="c">                reference immediately after appending the field, it is null.</span>
<span class="c">            */</span>
        
            <span class="k">var</span> <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
        
            <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
                <span class="nx">me</span><span class="o">.</span><span class="nx">_addListenersToForm</span><span class="o">();</span>
        
            <span class="o">},</span> <span class="m">0</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onFormReset</span>
<span class="c">        * @description &quot;reset&quot; event handler for the button&#39;s form.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event </span>
<span class="c">        * object passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onFormReset</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">),</span>
                <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">resetValue</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">);</span>
        
            <span class="o">}</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="k">instanceof</span> <span class="nx">Menu</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">resetValue</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">);</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onDocumentMouseDown</span>
<span class="c">        * @description &quot;mousedown&quot; event handler for the document.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onDocumentMouseDown</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">),</span>
                <span class="nx">oButtonElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">),</span>
                <span class="nx">oMenuElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">element</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oTarget</span> <span class="o">!=</span> <span class="nx">oButtonElement</span> <span class="o">&amp;&amp;</span> 
                <span class="o">!</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oButtonElement</span><span class="o">,</span> <span class="nx">oTarget</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
                <span class="nx">oTarget</span> <span class="o">!=</span> <span class="nx">oMenuElement</span> <span class="o">&amp;&amp;</span> 
                <span class="o">!</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oMenuElement</span><span class="o">,</span> <span class="nx">oTarget</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>
        
                <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> 
                    <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseDown</span><span class="o">);</span>    
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onOption</span>
<span class="c">        * @description &quot;option&quot; event handler for the button.</span>
<span class="c">        * @protected</span>
<span class="c">        * @param {Event} p_oEvent Object representing the DOM event object  </span>
<span class="c">        * passed back by the event utility (YAHOO.util.Event).</span>
<span class="c">        */</span>
        <span class="nx">_onOption</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="s2">&quot;yui-split-button-activeoption&quot;</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_showMenu</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>    
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onOverlayBeforeShow</span>
<span class="c">        * @description &quot;beforeshow&quot; event handler for the </span>
<span class="c">        * &lt;a href=&quot;YAHOO.widget.Overlay.html&quot;&gt;YAHOO.widget.Overlay&lt;/a&gt; instance </span>
<span class="c">        * serving as the button&#39;s menu.</span>
<span class="c">        * @private</span>
<span class="c">        * @param {String} p_sType String representing the name of the event  </span>
<span class="c">        * that was fired.</span>
<span class="c">        */</span>
        <span class="nx">_onOverlayBeforeShow</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>
        
            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">render</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">).</span><span class="nx">parentNode</span><span class="o">);</span>
            
            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">beforeShowEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onOverlayBeforeShow</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMenuShow</span>
<span class="c">        * @description &quot;show&quot; event handler for the button&#39;s menu.</span>
<span class="c">        * @private</span>
<span class="c">        * @param {String} p_sType String representing the name of the event  </span>
<span class="c">        * that was fired.</span>
<span class="c">        */</span>
        <span class="nx">_onMenuShow</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseDown</span><span class="o">,</span> 
                <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        
            <span class="k">var</span> <span class="nx">sTitle</span><span class="o">,</span>
                <span class="nx">sState</span><span class="o">;</span>
            
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;split&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">SPLITBUTTON_OPTION_VISIBLE_TITLE</span><span class="o">;</span>
                <span class="nx">sState</span> <span class="o">=</span> <span class="s2">&quot;activeoption&quot;</span><span class="o">;</span>
            
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
        
                <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">MENUBUTTON_MENU_VISIBLE_TITLE</span><span class="o">;</span>        
                <span class="nx">sState</span> <span class="o">=</span> <span class="s2">&quot;active&quot;</span><span class="o">;</span>
        
            <span class="o">}</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">addStateCSSClasses</span><span class="o">(</span><span class="nx">sState</span><span class="o">);</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMenuHide</span>
<span class="c">        * @description &quot;hide&quot; event handler for the button&#39;s menu.</span>
<span class="c">        * @private</span>
<span class="c">        * @param {String} p_sType String representing the name of the event  </span>
<span class="c">        * that was fired.</span>
<span class="c">        */</span>
        <span class="nx">_onMenuHide</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span><span class="o">)</span> <span class="o">{</span>
            
            <span class="k">var</span> <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">,</span>
                <span class="nx">sTitle</span><span class="o">,</span>
                <span class="nx">sState</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="k">instanceof</span> <span class="nx">Menu</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">_originalMaxHeight</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
            
                <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">,</span> 
                    <span class="k">this</span><span class="o">.</span><span class="nx">_originalMaxHeight</span><span class="o">);</span>
        
            <span class="o">}</span>
        
            
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;split&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">SPLITBUTTON_DEFAULT_TITLE</span><span class="o">;</span>
                <span class="nx">sState</span> <span class="o">=</span> <span class="s2">&quot;activeoption&quot;</span><span class="o">;</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
        
                <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">MENUBUTTON_DEFAULT_TITLE</span><span class="o">;</span>        
                <span class="nx">sState</span> <span class="o">=</span> <span class="s2">&quot;active&quot;</span><span class="o">;</span>
            <span class="o">}</span>
        
        
            <span class="k">this</span><span class="o">.</span><span class="nx">removeStateCSSClasses</span><span class="o">(</span><span class="nx">sState</span><span class="o">);</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;split&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMenuKeyDown</span>
<span class="c">        * @description &quot;keydown&quot; event handler for the button&#39;s menu.</span>
<span class="c">        * @private</span>
<span class="c">        * @param {String} p_sType String representing the name of the event  </span>
<span class="c">        * that was fired.</span>
<span class="c">        * @param {Array} p_aArgs Array of arguments sent when the event </span>
<span class="c">        * was fired.</span>
<span class="c">        */</span>
        <span class="nx">_onMenuKeyDown</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oEvent</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">)</span> <span class="o">==</span> <span class="m">27</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;split&quot;</span><span class="o">)</span> <span class="o">{</span>
                
                    <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
                
                <span class="o">}</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMenuRender</span>
<span class="c">        * @description &quot;render&quot; event handler for the button&#39;s menu.</span>
<span class="c">        * @private</span>
<span class="c">        * @param {String} p_sType String representing the name of the  </span>
<span class="c">        * event thatwas fired.</span>
<span class="c">        */</span>
        <span class="nx">_onMenuRender</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oButtonElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">),</span>
                <span class="nx">oButtonParent</span> <span class="o">=</span> <span class="nx">oButtonElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">,</span>
                <span class="nx">oMenuElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">element</span><span class="o">;</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oButtonParent</span> <span class="o">!=</span> <span class="nx">oMenuElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">oButtonParent</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oMenuElement</span><span class="o">);</span>
            
            <span class="o">}</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">));</span>

        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMenuItemSelected</span>
<span class="c">        * @description &quot;selectedchange&quot; event handler for each item in the </span>
<span class="c">        * button&#39;s menu.</span>
<span class="c">        * @private</span>
<span class="c">        * @param {String} p_sType String representing the name of the event  </span>
<span class="c">        * that was fired.</span>
<span class="c">        * @param {Array} p_aArgs Array of arguments sent when the event </span>
<span class="c">        * was fired.</span>
<span class="c">        * @param {Number} p_nItem Number representing the index of the menu</span>
<span class="c">        * item that subscribed to the event.</span>
<span class="c">        */</span>
        <span class="nx">_onMenuItemSelected</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_nItem</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">bSelected</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">bSelected</span><span class="o">)</span> <span class="o">{</span>
            
                <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">,</span> <span class="nx">p_nItem</span><span class="o">);</span>

            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMenuItemAdded</span>
<span class="c">        * @description &quot;itemadded&quot; event handler for the button&#39;s menu.</span>
<span class="c">        * @private</span>
<span class="c">        * @param {String} p_sType String representing the name of the event  </span>
<span class="c">        * that was fired.</span>
<span class="c">        * @param {Array} p_aArgs Array of arguments sent when the event</span>
<span class="c">        * was fired.</span>
<span class="c">        * @param {&lt;a href=&quot;YAHOO.widget.MenuItem.html&quot;&gt;</span>
<span class="c">        * YAHOO.widget.MenuItem&lt;/a&gt;} p_oItem Object representing the menu </span>
<span class="c">        * item that subscribed to the event.</span>
<span class="c">        */</span>
        <span class="nx">_onMenuItemAdded</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">)</span> <span class="o">{</span>
            
            <span class="k">var</span> <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
        
            <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">subscribeToConfigEvent</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">_onMenuItemSelected</span><span class="o">,</span> 
                <span class="nx">oItem</span><span class="o">.</span><span class="nx">index</span><span class="o">,</span> 
                <span class="k">this</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method _onMenuClick</span>
<span class="c">        * @description &quot;click&quot; event handler for the button&#39;s menu.</span>
<span class="c">        * @private</span>
<span class="c">        * @param {String} p_sType String representing the name of the event  </span>
<span class="c">        * that was fired.</span>
<span class="c">        * @param {Array} p_aArgs Array of arguments sent when the event </span>
<span class="c">        * was fired.</span>
<span class="c">        */</span>
        <span class="nx">_onMenuClick</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">1</span><span class="o">],</span>
                <span class="nx">oSrcElement</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">);</span>
            
                <span class="k">if</span> <span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">submitForm</span><span class="o">();</span>
            
                <span class="o">}</span>
            
                <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        
        <span class="c">// Public methods</span>
<span class="c"></span>        
        
        <span class="c">/**</span>
<span class="c">        * @method createButtonElement</span>
<span class="c">        * @description Creates the button&#39;s HTML elements.</span>
<span class="c">        * @param {String} p_sType String indicating the type of element </span>
<span class="c">        * to create.</span>
<span class="c">        * @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">        * level-one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;}</span>
<span class="c">        */</span>
        <span class="nx">createButtonElement</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sNodeName</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">NODE_NAME</span><span class="o">,</span>
                <span class="nx">oElement</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="nx">sNodeName</span><span class="o">);</span>
        
            <span class="nx">oElement</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span>  <span class="s2">&quot;&lt;&quot;</span> <span class="o">+</span> <span class="nx">sNodeName</span> <span class="o">+</span> <span class="s2">&quot; class=\&quot;first-child\&quot;&gt;&quot;</span> <span class="o">+</span> 
                <span class="o">(</span><span class="nx">p_sType</span> <span class="o">==</span> <span class="s2">&quot;link&quot;</span> <span class="o">?</span> <span class="s2">&quot;&lt;a&gt;&lt;/a&gt;&quot;</span> <span class="o">:</span> 
                <span class="s2">&quot;&lt;button type=\&quot;button\&quot;&gt;&lt;/button&gt;&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot;&lt;/&quot;</span> <span class="o">+</span> <span class="nx">sNodeName</span> <span class="o">+</span> <span class="s2">&quot;&gt;&quot;</span><span class="o">;</span>
        
            <span class="k">return</span> <span class="nx">oElement</span><span class="o">;</span>
        
        <span class="o">},</span>

        
        <span class="c">/**</span>
<span class="c">        * @method addStateCSSClasses</span>
<span class="c">        * @description Appends state-specific CSS classes to the button&#39;s root </span>
<span class="c">        * DOM element.</span>
<span class="c">        */</span>
        <span class="nx">addStateCSSClasses</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sState</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">p_sState</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">p_sState</span> <span class="o">!=</span> <span class="s2">&quot;activeoption&quot;</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span> <span class="o">+</span> <span class="o">(</span><span class="s2">&quot;-&quot;</span> <span class="o">+</span> <span class="nx">p_sState</span><span class="o">));</span>
        
                <span class="o">}</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;yui-&quot;</span> <span class="o">+</span> <span class="nx">sType</span> <span class="o">+</span> <span class="o">(</span><span class="s2">&quot;-button-&quot;</span> <span class="o">+</span> <span class="nx">p_sState</span><span class="o">));</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method removeStateCSSClasses</span>
<span class="c">        * @description Removes state-specific CSS classes to the button&#39;s root </span>
<span class="c">        * DOM element.</span>
<span class="c">        */</span>
        <span class="nx">removeStateCSSClasses</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sState</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">p_sState</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span> <span class="o">+</span> <span class="o">(</span><span class="s2">&quot;-&quot;</span> <span class="o">+</span> <span class="nx">p_sState</span><span class="o">));</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="s2">&quot;yui-&quot;</span> <span class="o">+</span> <span class="nx">sType</span> <span class="o">+</span> <span class="o">(</span><span class="s2">&quot;-button-&quot;</span> <span class="o">+</span> <span class="nx">p_sState</span><span class="o">));</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method createHiddenFields</span>
<span class="c">        * @description Creates the button&#39;s hidden form field and appends it </span>
<span class="c">        * to its parent form.</span>
<span class="c">        * @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">        * level-one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;|Array}</span>
<span class="c">        */</span>
        <span class="nx">createHiddenFields</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">removeHiddenFields</span><span class="o">();</span>
        
            <span class="k">var</span> <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">(),</span>
                <span class="nx">oButtonField</span><span class="o">,</span>
                <span class="nx">sType</span><span class="o">,</span>     
                <span class="nx">bCheckable</span><span class="o">,</span>
                <span class="nx">oMenu</span><span class="o">,</span>
                <span class="nx">oMenuItem</span><span class="o">,</span>
                <span class="nx">sName</span><span class="o">,</span>
                <span class="nx">oValue</span><span class="o">,</span>
                <span class="nx">oMenuField</span><span class="o">;</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oForm</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>
                <span class="nx">bCheckable</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">);</span>
        
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">bCheckable</span> <span class="o">||</span> <span class="o">(</span><span class="nx">m_oSubmitTrigger</span> <span class="o">==</span> <span class="k">this</span><span class="o">))</span> <span class="o">{</span>
                
                    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Creating hidden field.&quot;</span><span class="o">);</span>
        
                    <span class="nx">oButtonField</span> <span class="o">=</span> <span class="nx">createInputElement</span><span class="o">(</span>
                                    <span class="o">(</span><span class="nx">bCheckable</span> <span class="o">?</span> <span class="nx">sType</span> <span class="o">:</span> <span class="s2">&quot;hidden&quot;</span><span class="o">),</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">),</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;value&quot;</span><span class="o">),</span>
                                    <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">));</span>
            
            
                    <span class="k">if</span> <span class="o">(</span><span class="nx">oButtonField</span><span class="o">)</span> <span class="o">{</span>
            
                        <span class="k">if</span> <span class="o">(</span><span class="nx">bCheckable</span><span class="o">)</span> <span class="o">{</span>
            
                            <span class="nx">oButtonField</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>
            
                        <span class="o">}</span>
            
                        <span class="nx">oForm</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oButtonField</span><span class="o">);</span>
            
                    <span class="o">}</span>
        
                <span class="o">}</span>
                    
        
                <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>
            
            
                <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oMenu</span> <span class="k">instanceof</span> <span class="nx">Menu</span><span class="o">))</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Creating hidden field for menu.&quot;</span><span class="o">);</span>
        
                    <span class="nx">oMenuField</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">;</span>
                    <span class="nx">oMenuItem</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">getItem</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">));</span>

                    <span class="k">if</span> <span class="o">(</span><span class="nx">oMenuItem</span><span class="o">)</span> <span class="o">{</span>

                        <span class="k">if</span> <span class="o">(</span><span class="nx">oMenuField</span> <span class="o">&amp;&amp;</span> 
                            <span class="nx">oMenuField</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">)</span> <span class="o">{</span>
            
                            <span class="nx">oForm</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oMenuField</span><span class="o">);</span>
                            <span class="nx">oMenuField</span><span class="o">.</span><span class="nx">selectedIndex</span> <span class="o">=</span> <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">index</span><span class="o">;</span>
            
                        <span class="o">}</span>
                        <span class="k">else</span> <span class="o">{</span>
            
                            <span class="nx">oValue</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">value</span> <span class="o">===</span> <span class="kc">null</span> <span class="o">||</span> 
                                        <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">value</span> <span class="o">===</span> <span class="s2">&quot;&quot;</span><span class="o">)</span> <span class="o">?</span> 
                                        <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;text&quot;</span><span class="o">)</span> <span class="o">:</span> 
                                        <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
            
                            <span class="nx">sName</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">);</span>
            
                            <span class="k">if</span> <span class="o">(</span><span class="nx">oValue</span> <span class="o">&amp;&amp;</span> <span class="nx">sName</span><span class="o">)</span> <span class="o">{</span>
            
                                <span class="nx">oMenuField</span> <span class="o">=</span> <span class="nx">createInputElement</span><span class="o">(</span><span class="s2">&quot;hidden&quot;</span><span class="o">,</span> 
                                                    <span class="o">(</span><span class="nx">sName</span> <span class="o">+</span> <span class="s2">&quot;_options&quot;</span><span class="o">),</span>
                                                    <span class="nx">oValue</span><span class="o">);</span>
            
                                <span class="nx">oForm</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oMenuField</span><span class="o">);</span>
            
                            <span class="o">}</span>
            
                        <span class="o">}</span>  
                    
                    <span class="o">}</span>
        
                <span class="o">}</span>
            
            
                <span class="k">if</span> <span class="o">(</span><span class="nx">oButtonField</span> <span class="o">&amp;&amp;</span> <span class="nx">oMenuField</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_hiddenFields</span> <span class="o">=</span> <span class="o">[</span><span class="nx">oButtonField</span><span class="o">,</span> <span class="nx">oMenuField</span><span class="o">];</span>
        
                <span class="o">}</span>
                <span class="k">else</span> <span class="k">if</span> <span class="o">(!</span><span class="nx">oButtonField</span> <span class="o">&amp;&amp;</span> <span class="nx">oMenuField</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_hiddenFields</span> <span class="o">=</span> <span class="nx">oMenuField</span><span class="o">;</span>
                
                <span class="o">}</span>
                <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">oButtonField</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oMenuField</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_hiddenFields</span> <span class="o">=</span> <span class="nx">oButtonField</span><span class="o">;</span>
                
                <span class="o">}</span>
        
        
                <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_hiddenFields</span><span class="o">;</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method removeHiddenFields</span>
<span class="c">        * @description Removes the button&#39;s hidden form field(s) from its </span>
<span class="c">        * parent form.</span>
<span class="c">        */</span>
        <span class="nx">removeHiddenFields</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oField</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_hiddenFields</span><span class="o">,</span>
                <span class="nx">nFields</span><span class="o">,</span>
                <span class="nx">i</span><span class="o">;</span>
        
            <span class="k">function</span> <span class="nx">removeChild</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">inDocument</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">))</span> <span class="o">{</span>
        
                    <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">);</span>
                
                <span class="o">}</span>
                
            <span class="o">}</span>
            
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oField</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oField</span><span class="o">))</span> <span class="o">{</span>
        
                    <span class="nx">nFields</span> <span class="o">=</span> <span class="nx">oField</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
                    
                    <span class="k">if</span> <span class="o">(</span><span class="nx">nFields</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                    
                        <span class="nx">i</span> <span class="o">=</span> <span class="nx">nFields</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
                        
                        <span class="k">do</span> <span class="o">{</span>
        
                            <span class="nx">removeChild</span><span class="o">(</span><span class="nx">oField</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
        
                        <span class="o">}</span>
                        <span class="k">while</span> <span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
                    
                    <span class="o">}</span>
                
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
        
                    <span class="nx">removeChild</span><span class="o">(</span><span class="nx">oField</span><span class="o">);</span>
        
                <span class="o">}</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_hiddenFields</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method submitForm</span>
<span class="c">        * @description Submits the form to which the button belongs.  Returns  </span>
<span class="c">        * true if the form was submitted successfully, false if the submission </span>
<span class="c">        * was cancelled.</span>
<span class="c">        * @protected</span>
<span class="c">        * @return {Boolean}</span>
<span class="c">        */</span>
        <span class="nx">submitForm</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">(),</span>
        
                <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">),</span>
        
                <span class="c">/*</span>
<span class="c">                    Boolean indicating if the event fired successfully </span>
<span class="c">                    (was not cancelled by any handlers)</span>
<span class="c">                */</span>
        
                <span class="nx">bSubmitForm</span> <span class="o">=</span> <span class="kc">false</span><span class="o">,</span>
                
                <span class="nx">oEvent</span><span class="o">;</span>
        
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span> <span class="o">||</span> 
                    <span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span><span class="o">))</span> 
                <span class="o">{</span>
        
                    <span class="nx">m_oSubmitTrigger</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
                    
                <span class="o">}</span>
        
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">env</span><span class="o">.</span><span class="nx">ua</span><span class="o">.</span><span class="nx">ie</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">bSubmitForm</span> <span class="o">=</span> <span class="nx">oForm</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;onsubmit&quot;</span><span class="o">);</span>
        
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>  <span class="c">// Gecko, Opera, and Safari</span>
<span class="c"></span>        
                    <span class="nx">oEvent</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;HTMLEvents&quot;</span><span class="o">);</span>
                    <span class="nx">oEvent</span><span class="o">.</span><span class="nx">initEvent</span><span class="o">(</span><span class="s2">&quot;submit&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        
                    <span class="nx">bSubmitForm</span> <span class="o">=</span> <span class="nx">oForm</span><span class="o">.</span><span class="nx">dispatchEvent</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>
        
                <span class="o">}</span>
        
        
                <span class="c">/*</span>
<span class="c">                    In IE and Safari, dispatching a &quot;submit&quot; event to a form </span>
<span class="c">                    WILL cause the form&#39;s &quot;submit&quot; event to fire, but WILL NOT </span>
<span class="c">                    submit the form.  Therefore, we need to call the &quot;submit&quot; </span>
<span class="c">                    method as well.</span>
<span class="c">                */</span>
              
                <span class="k">if</span> <span class="o">((</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">env</span><span class="o">.</span><span class="nx">ua</span><span class="o">.</span><span class="nx">ie</span> <span class="o">||</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">env</span><span class="o">.</span><span class="nx">ua</span><span class="o">.</span><span class="nx">webkit</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">bSubmitForm</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">oForm</span><span class="o">.</span><span class="nx">submit</span><span class="o">();</span>
                
                <span class="o">}</span>
            
            <span class="o">}</span>
        
            <span class="k">return</span> <span class="nx">bSubmitForm</span><span class="o">;</span>
            
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method init</span>
<span class="c">        * @description The Button class&#39;s initialization method.</span>
<span class="c">        * @param {String} p_oElement String specifying the id attribute of the </span>
<span class="c">        * &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt;, &lt;code&gt;&amp;#60;button&amp;#62;&lt;/code&gt;,</span>
<span class="c">        * &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt;, or &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt; element to </span>
<span class="c">        * be used to create the button.</span>
<span class="c">        * @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">        * level-one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;|&lt;a href=&quot;http://</span>
<span class="c">        * www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html</span>
<span class="c">        * #ID-34812697&quot;&gt;HTMLButtonElement&lt;/a&gt;|&lt;a href=&quot;http://www.w3.org/TR</span>
<span class="c">        * /2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-33759296&quot;&gt;</span>
<span class="c">        * HTMLElement&lt;/a&gt;} p_oElement Object reference for the </span>
<span class="c">        * &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt;, &lt;code&gt;&amp;#60;button&amp;#62;&lt;/code&gt;, </span>
<span class="c">        * &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt;, or &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt; element to be </span>
<span class="c">        * used to create the button.</span>
<span class="c">        * @param {Object} p_oElement Object literal specifying a set of </span>
<span class="c">        * configuration attributes used to create the button.</span>
<span class="c">        * @param {Object} p_oAttributes Optional. Object literal specifying a </span>
<span class="c">        * set of configuration attributes used to create the button.</span>
<span class="c">        */</span>
        <span class="nx">init</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oElement</span><span class="o">,</span> <span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sNodeName</span> <span class="o">=</span> <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;link&quot;</span> <span class="o">?</span> <span class="s2">&quot;a&quot;</span> <span class="o">:</span> <span class="s2">&quot;button&quot;</span><span class="o">,</span>
                <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">srcelement</span><span class="o">,</span>
                <span class="nx">oButton</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="nx">sNodeName</span><span class="o">)[</span><span class="m">0</span><span class="o">],</span>
                <span class="nx">oInput</span><span class="o">;</span>
        

            <span class="k">if</span> <span class="o">(!</span><span class="nx">oButton</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oInput</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="s2">&quot;input&quot;</span><span class="o">)[</span><span class="m">0</span><span class="o">];</span>


                <span class="k">if</span> <span class="o">(</span><span class="nx">oInput</span><span class="o">)</span> <span class="o">{</span>

                    <span class="nx">oButton</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;button&quot;</span><span class="o">);</span>
                    <span class="nx">oButton</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">,</span> <span class="s2">&quot;button&quot;</span><span class="o">);</span>

                    <span class="nx">oInput</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">replaceChild</span><span class="o">(</span><span class="nx">oButton</span><span class="o">,</span> <span class="nx">oInput</span><span class="o">);</span>
                
                <span class="o">}</span>

            <span class="o">}</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_button</span> <span class="o">=</span> <span class="nx">oButton</span><span class="o">;</span>
        

            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">init</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">p_oElement</span><span class="o">,</span> 
                <span class="nx">p_oAttributes</span><span class="o">);</span>
        
        
            <span class="nx">m_oButtons</span><span class="o">[</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;id&quot;</span><span class="o">)]</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
        
        
            <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span><span class="o">);</span>
            
            <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;yui-&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot;-button&quot;</span><span class="o">);</span>
        
            <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">,</span> <span class="s2">&quot;focus&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFocus</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;mouseover&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseOver</span><span class="o">);</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onClick</span><span class="o">);</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;appendTo&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onAppendTo</span><span class="o">);</span>
            
        
            <span class="k">var</span> <span class="nx">oContainer</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;container&quot;</span><span class="o">),</span>
                <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">),</span>
                <span class="nx">bElInDoc</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">inDocument</span><span class="o">(</span><span class="nx">oElement</span><span class="o">),</span>
                <span class="nx">oParentNode</span><span class="o">;</span>


            <span class="k">if</span> <span class="o">(</span><span class="nx">oContainer</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span> <span class="o">!=</span> <span class="nx">oElement</span><span class="o">)</span> <span class="o">{</span>
                
                    <span class="nx">oParentNode</span> <span class="o">=</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>

                    <span class="k">if</span> <span class="o">(</span><span class="nx">oParentNode</span><span class="o">)</span> <span class="o">{</span>
                    
                        <span class="nx">oParentNode</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oSrcElement</span><span class="o">);</span>
                    
                    <span class="o">}</span>

                <span class="o">}</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">oContainer</span><span class="o">))</span> <span class="o">{</span>
        
                    <span class="nx">Event</span><span class="o">.</span><span class="nx">onContentReady</span><span class="o">(</span><span class="nx">oContainer</span><span class="o">,</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
                        <span class="k">this</span><span class="o">.</span><span class="nx">appendTo</span><span class="o">(</span><span class="nx">oContainer</span><span class="o">);</span>
                    
                    <span class="o">},</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">appendTo</span><span class="o">(</span><span class="nx">oContainer</span><span class="o">);</span>
        
                <span class="o">}</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(!</span><span class="nx">bElInDoc</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span> <span class="o">!=</span> <span class="nx">oElement</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oParentNode</span> <span class="o">=</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">oParentNode</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;beforeAppendTo&quot;</span><span class="o">,</span> <span class="o">{</span>
                        <span class="nx">type</span><span class="o">:</span> <span class="s2">&quot;beforeAppendTo&quot;</span><span class="o">,</span>
                        <span class="nx">target</span><span class="o">:</span> <span class="nx">oParentNode</span>
                    <span class="o">});</span>
            
                    <span class="nx">oParentNode</span><span class="o">.</span><span class="nx">replaceChild</span><span class="o">(</span><span class="nx">oElement</span><span class="o">,</span> <span class="nx">oSrcElement</span><span class="o">);</span>
            
                    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;appendTo&quot;</span><span class="o">,</span> <span class="o">{</span>
                        <span class="nx">type</span><span class="o">:</span> <span class="s2">&quot;appendTo&quot;</span><span class="o">,</span>
                        <span class="nx">target</span><span class="o">:</span> <span class="nx">oParentNode</span>
                    <span class="o">});</span>
                
                <span class="o">}</span>
        
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;link&quot;</span> <span class="o">&amp;&amp;</span> <span class="nx">bElInDoc</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> 
                <span class="nx">oSrcElement</span> <span class="o">==</span> <span class="nx">oElement</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_addListenersToForm</span><span class="o">();</span>
        
            <span class="o">}</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Initialization completed.&quot;</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method initAttributes</span>
<span class="c">        * @description Initializes all of the configuration attributes used to  </span>
<span class="c">        * create the button.</span>
<span class="c">        * @param {Object} p_oAttributes Object literal specifying a set of </span>
<span class="c">        * configuration attributes used to create the button.</span>
<span class="c">        */</span>
        <span class="nx">initAttributes</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oAttributes</span> <span class="o">=</span> <span class="nx">p_oAttributes</span> <span class="o">||</span> <span class="o">{};</span>
        
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">initAttributes</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> 
                <span class="nx">oAttributes</span><span class="o">);</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute type</span>
<span class="c">            * @description String specifying the button&#39;s type.  Possible </span>
<span class="c">            * values are: &quot;push,&quot; &quot;link,&quot; &quot;submit,&quot; &quot;reset,&quot; &quot;checkbox,&quot; </span>
<span class="c">            * &quot;radio,&quot; &quot;menu,&quot; and &quot;split.&quot;</span>
<span class="c">            * @default &quot;push&quot;</span>
<span class="c">            * @type String</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="o">(</span><span class="nx">oAttributes</span><span class="o">.</span><span class="nx">type</span> <span class="o">||</span> <span class="s2">&quot;push&quot;</span><span class="o">),</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
                <span class="nx">writeOnce</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setType</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute label</span>
<span class="c">            * @description String specifying the button&#39;s text label </span>
<span class="c">            * or innerHTML.</span>
<span class="c">            * @default null</span>
<span class="c">            * @type String</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;label&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="k">label</span><span class="o">,</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setLabel</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute value</span>
<span class="c">            * @description Object specifying the value for the button.</span>
<span class="c">            * @default null</span>
<span class="c">            * @type Object</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;value&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">value</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute name</span>
<span class="c">            * @description String specifying the name for the button.</span>
<span class="c">            * @default null</span>
<span class="c">            * @type String</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">name</span><span class="o">,</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute tabindex</span>
<span class="c">            * @description Number specifying the tabindex for the button.</span>
<span class="c">            * @default null</span>
<span class="c">            * @type Number</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;tabindex&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">tabindex</span><span class="o">,</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setTabIndex</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute title</span>
<span class="c">            * @description String specifying the title for the button.</span>
<span class="c">            * @default null</span>
<span class="c">            * @type String</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">configureAttribute</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">title</span><span class="o">,</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setTitle</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute disabled</span>
<span class="c">            * @description Boolean indicating if the button should be disabled.  </span>
<span class="c">            * (Disabled buttons are dimmed and will not respond to user input </span>
<span class="c">            * or fire events.  Does not apply to button&#39;s of type &quot;link.&quot;)</span>
<span class="c">            * @default false</span>
<span class="c">            * @type Boolean</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="o">(</span><span class="nx">oAttributes</span><span class="o">.</span><span class="nx">disabled</span> <span class="o">||</span> <span class="kc">false</span><span class="o">),</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isBoolean</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setDisabled</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute href</span>
<span class="c">            * @description String specifying the href for the button.  Applies</span>
<span class="c">            * only to buttons of type &quot;link.&quot;</span>
<span class="c">            * @type String</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;href&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">href</span><span class="o">,</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setHref</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute target</span>
<span class="c">            * @description String specifying the target for the button.  </span>
<span class="c">            * Applies only to buttons of type &quot;link.&quot;</span>
<span class="c">            * @type String</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;target&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">target</span><span class="o">,</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setTarget</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute checked</span>
<span class="c">            * @description Boolean indicating if the button is checked. </span>
<span class="c">            * Applies only to buttons of type &quot;radio&quot; and &quot;checkbox.&quot;</span>
<span class="c">            * @default false</span>
<span class="c">            * @type Boolean</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="o">(</span><span class="nx">oAttributes</span><span class="o">.</span><span class="nx">checked</span> <span class="o">||</span> <span class="kc">false</span><span class="o">),</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isBoolean</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setChecked</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute container</span>
<span class="c">            * @description HTML element reference or string specifying the id </span>
<span class="c">            * attribute of the HTML element that the button&#39;s markup should be </span>
<span class="c">            * rendered into.</span>
<span class="c">            * @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">            * level-one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;|String</span>
<span class="c">            * @default null</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;container&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">container</span><span class="o">,</span>
                <span class="nx">writeOnce</span><span class="o">:</span> <span class="kc">true</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute srcelement</span>
<span class="c">            * @description Object reference to the HTML element (either </span>
<span class="c">            * &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; or &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt;) </span>
<span class="c">            * used to create the button.</span>
<span class="c">            * @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">            * level-one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;|String</span>
<span class="c">            * @default null</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">srcelement</span><span class="o">,</span>
                <span class="nx">writeOnce</span><span class="o">:</span> <span class="kc">true</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute menu</span>
<span class="c">            * @description Object specifying the menu for the button.  </span>
<span class="c">            * The value can be one of the following:</span>
<span class="c">            * &lt;ul&gt;</span>
<span class="c">            * &lt;li&gt;Object specifying a &lt;a href=&quot;YAHOO.widget.Menu.html&quot;&gt;</span>
<span class="c">            * YAHOO.widget.Menu&lt;/a&gt; instance.&lt;/li&gt;</span>
<span class="c">            * &lt;li&gt;Object specifying a &lt;a href=&quot;YAHOO.widget.Overlay.html&quot;&gt;</span>
<span class="c">            * YAHOO.widget.Overlay&lt;/a&gt; instance.&lt;/li&gt;</span>
<span class="c">            * &lt;li&gt;String specifying the id attribute of the &lt;code&gt;&amp;#60;div&amp;#62;</span>
<span class="c">            * &lt;/code&gt; element used to create the menu.  By default the menu </span>
<span class="c">            * will be created as an instance of </span>
<span class="c">            * &lt;a href=&quot;YAHOO.widget.Overlay.html&quot;&gt;YAHOO.widget.Overlay&lt;/a&gt;.  </span>
<span class="c">            * If the &lt;a href=&quot;YAHOO.widget.Menu.html#CSS_CLASS_NAME&quot;&gt;</span>
<span class="c">            * default CSS class name for YAHOO.widget.Menu&lt;/a&gt; is applied to </span>
<span class="c">            * the &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element, it will be created as an</span>
<span class="c">            * instance of &lt;a href=&quot;YAHOO.widget.Menu.html&quot;&gt;YAHOO.widget.Menu</span>
<span class="c">            * &lt;/a&gt;.&lt;/li&gt;&lt;li&gt;String specifying the id attribute of the </span>
<span class="c">            * &lt;code&gt;&amp;#60;select&amp;#62;&lt;/code&gt; element used to create the menu.</span>
<span class="c">            * &lt;/li&gt;&lt;li&gt;Object specifying the &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element</span>
<span class="c">            * used to create the menu.&lt;/li&gt;</span>
<span class="c">            * &lt;li&gt;Object specifying the &lt;code&gt;&amp;#60;select&amp;#62;&lt;/code&gt; element</span>
<span class="c">            * used to create the menu.&lt;/li&gt;</span>
<span class="c">            * &lt;li&gt;Array of object literals, each representing a set of </span>
<span class="c">            * &lt;a href=&quot;YAHOO.widget.MenuItem.html&quot;&gt;YAHOO.widget.MenuItem&lt;/a&gt; </span>
<span class="c">            * configuration attributes.&lt;/li&gt;</span>
<span class="c">            * &lt;li&gt;Array of strings representing the text labels for each menu </span>
<span class="c">            * item in the menu.&lt;/li&gt;</span>
<span class="c">            * &lt;/ul&gt;</span>
<span class="c">            * @type &lt;a href=&quot;YAHOO.widget.Menu.html&quot;&gt;YAHOO.widget.Menu&lt;/a&gt;|&lt;a </span>
<span class="c">            * href=&quot;YAHOO.widget.Overlay.html&quot;&gt;YAHOO.widget.Overlay&lt;/a&gt;|&lt;a </span>
<span class="c">            * href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">            * one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;|String|Array</span>
<span class="c">            * @default null</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;menu&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setMenu</span><span class="o">,</span>
                <span class="nx">writeOnce</span><span class="o">:</span> <span class="kc">true</span>
            
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute lazyloadmenu</span>
<span class="c">            * @description Boolean indicating the value to set for the </span>
<span class="c">            * &lt;a href=&quot;YAHOO.widget.Menu.html#lazyLoad&quot;&gt;&quot;lazyload&quot;&lt;/a&gt;</span>
<span class="c">            * configuration property of the button&#39;s menu.  Setting </span>
<span class="c">            * &quot;lazyloadmenu&quot; to &lt;code&gt;true &lt;/code&gt; will defer rendering of </span>
<span class="c">            * the button&#39;s menu until the first time it is made visible.  </span>
<span class="c">            * If &quot;lazyloadmenu&quot; is set to &lt;code&gt;false&lt;/code&gt;, the button&#39;s </span>
<span class="c">            * menu will be rendered immediately if the button is in the </span>
<span class="c">            * document, or in response to the button&#39;s &quot;appendTo&quot; event if </span>
<span class="c">            * the button is not yet in the document.  In either case, the </span>
<span class="c">            * menu is rendered into the button&#39;s parent HTML element.  </span>
<span class="c">            * &lt;em&gt;This attribute does not apply if a </span>
<span class="c">            * &lt;a href=&quot;YAHOO.widget.Menu.html&quot;&gt;YAHOO.widget.Menu&lt;/a&gt; or </span>
<span class="c">            * &lt;a href=&quot;YAHOO.widget.Overlay.html&quot;&gt;YAHOO.widget.Overlay&lt;/a&gt; </span>
<span class="c">            * instance is passed as the value of the button&#39;s &quot;menu&quot; </span>
<span class="c">            * configuration attribute. &lt;a href=&quot;YAHOO.widget.Menu.html&quot;&gt;</span>
<span class="c">            * YAHOO.widget.Menu&lt;/a&gt; or &lt;a href=&quot;YAHOO.widget.Overlay.html&quot;&gt;</span>
<span class="c">            * YAHOO.widget.Overlay&lt;/a&gt; instances should be rendered before </span>
<span class="c">            * being set as the value for the &quot;menu&quot; configuration </span>
<span class="c">            * attribute.&lt;/em&gt;</span>
<span class="c">            * @default true</span>
<span class="c">            * @type Boolean</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;lazyloadmenu&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="o">(</span><span class="nx">oAttributes</span><span class="o">.</span><span class="nx">lazyloadmenu</span> <span class="o">===</span> <span class="kc">false</span> <span class="o">?</span> <span class="kc">false</span> <span class="o">:</span> <span class="kc">true</span><span class="o">),</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isBoolean</span><span class="o">,</span>
                <span class="nx">writeOnce</span><span class="o">:</span> <span class="kc">true</span>
        
            <span class="o">});</span>


            <span class="c">/**</span>
<span class="c">            * @attribute menuclassname</span>
<span class="c">            * @description String representing the CSS class name to be </span>
<span class="c">            * applied to the root element of the button&#39;s menu.</span>
<span class="c">            * @type String</span>
<span class="c">            * @default &quot;yui-button-menu&quot;</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;menuclassname&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="o">(</span><span class="nx">oAttributes</span><span class="o">.</span><span class="nx">menuclassname</span> <span class="o">||</span> <span class="s2">&quot;yui-button-menu&quot;</span><span class="o">),</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setMenuClassName</span><span class="o">,</span>
                <span class="nx">writeOnce</span><span class="o">:</span> <span class="kc">true</span>
        
            <span class="o">});</span>        


            <span class="c">/**</span>
<span class="c">            * @attribute selectedMenuItem</span>
<span class="c">            * @description Number representing the index of the item in the </span>
<span class="c">            * button&#39;s menu that is currently selected.</span>
<span class="c">            * @type Number</span>
<span class="c">            * @default null</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setSelectedMenuItem</span>
        
            <span class="o">});</span>
        
        
            <span class="c">/**</span>
<span class="c">            * @attribute onclick</span>
<span class="c">            * @description Object literal representing the code to be executed  </span>
<span class="c">            * when the button is clicked.  Format:&lt;br&gt; &lt;code&gt; {&lt;br&gt; </span>
<span class="c">            * &lt;strong&gt;fn:&lt;/strong&gt; Function,   &amp;#47;&amp;#47; The handler to call </span>
<span class="c">            * when the event fires.&lt;br&gt; &lt;strong&gt;obj:&lt;/strong&gt; Object, </span>
<span class="c">            * &amp;#47;&amp;#47; An object to pass back to the handler.&lt;br&gt; </span>
<span class="c">            * &lt;strong&gt;scope:&lt;/strong&gt; Object &amp;#47;&amp;#47;  The object to use </span>
<span class="c">            * for the scope of the handler.&lt;br&gt; } &lt;/code&gt;</span>
<span class="c">            * @type Object</span>
<span class="c">            * @default null</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;onclick&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">onclick</span><span class="o">,</span>
                <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setOnClick</span>
            
            <span class="o">});</span>


            <span class="c">/**</span>
<span class="c">            * @attribute focusmenu</span>
<span class="c">            * @description Boolean indicating whether or not the button&#39;s menu </span>
<span class="c">            * should be focused when it is made visible.</span>
<span class="c">            * @type Boolean</span>
<span class="c">            * @default true</span>
<span class="c">            */</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;focusmenu&quot;</span><span class="o">,</span> <span class="o">{</span>
        
                <span class="nx">value</span><span class="o">:</span> <span class="o">(</span><span class="nx">oAttributes</span><span class="o">.</span><span class="nx">focusmenu</span> <span class="o">===</span> <span class="kc">false</span> <span class="o">?</span> <span class="kc">false</span> <span class="o">:</span> <span class="kc">true</span><span class="o">),</span>
                <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isBoolean</span>
        
            <span class="o">});</span>

        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method focus</span>
<span class="c">        * @description Causes the button to receive the focus and fires the </span>
<span class="c">        * button&#39;s &quot;focus&quot; event.</span>
<span class="c">        */</span>
        <span class="nx">focus</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
            
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method blur</span>
<span class="c">        * @description Causes the button to lose focus and fires the button&#39;s</span>
<span class="c">        * &quot;blur&quot; event.</span>
<span class="c">        */</span>
        <span class="nx">blur</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">blur</span><span class="o">();</span>
        
            <span class="o">}</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method hasFocus</span>
<span class="c">        * @description Returns a boolean indicating whether or not the button </span>
<span class="c">        * has focus.</span>
<span class="c">        * @return {Boolean}</span>
<span class="c">        */</span>
        <span class="nx">hasFocus</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">return</span> <span class="o">(</span><span class="nx">m_oFocusedButton</span> <span class="o">==</span> <span class="k">this</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method isActive</span>
<span class="c">        * @description Returns a boolean indicating whether or not the button </span>
<span class="c">        * is active.</span>
<span class="c">        * @return {Boolean}</span>
<span class="c">        */</span>
        <span class="nx">isActive</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span> <span class="o">+</span> <span class="s2">&quot;-active&quot;</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method getMenu</span>
<span class="c">        * @description Returns a reference to the button&#39;s menu.</span>
<span class="c">        * @return {&lt;a href=&quot;YAHOO.widget.Overlay.html&quot;&gt;</span>
<span class="c">        * YAHOO.widget.Overlay&lt;/a&gt;|&lt;a </span>
<span class="c">        * href=&quot;YAHOO.widget.Menu.html&quot;&gt;YAHOO.widget.Menu&lt;/a&gt;}</span>
<span class="c">        */</span>
        <span class="nx">getMenu</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method getForm</span>
<span class="c">        * @description Returns a reference to the button&#39;s parent form.</span>
<span class="c">        * @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-</span>
<span class="c">        * 20000929/level-one-html.html#ID-40002357&quot;&gt;HTMLFormElement&lt;/a&gt;}</span>
<span class="c">        */</span>
        <span class="nx">getForm</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">form</span><span class="o">;</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/** </span>
<span class="c">        * @method getHiddenFields</span>
<span class="c">        * @description Returns an &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element or </span>
<span class="c">        * array of form elements used to represent the button when its parent </span>
<span class="c">        * form is submitted.  </span>
<span class="c">        * @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">        * level-one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;|Array}</span>
<span class="c">        */</span>
        <span class="nx">getHiddenFields</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_hiddenFields</span><span class="o">;</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method destroy</span>
<span class="c">        * @description Removes the button&#39;s element from its parent element and </span>
<span class="c">        * removes all event handlers.</span>
<span class="c">        */</span>
        <span class="nx">destroy</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Destroying ...&quot;</span><span class="o">);</span>
        
            <span class="k">var</span> <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">),</span>
                <span class="nx">oParentNode</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">,</span>
                <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">,</span>
                <span class="nx">aButtons</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">oMenu</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Destroying menu.&quot;</span><span class="o">);</span>

                <span class="k">if</span> <span class="o">(</span><span class="nx">m_oOverlayManager</span><span class="o">.</span><span class="nx">find</span><span class="o">(</span><span class="nx">oMenu</span><span class="o">))</span> <span class="o">{</span>

                    <span class="nx">m_oOverlayManager</span><span class="o">.</span><span class="nx">remove</span><span class="o">(</span><span class="nx">oMenu</span><span class="o">);</span>

                <span class="o">}</span>
        
                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">destroy</span><span class="o">();</span>
        
            <span class="o">}</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Removing DOM event listeners.&quot;</span><span class="o">);</span>
        
            <span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">oElement</span><span class="o">);</span>
            <span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">);</span>
            <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseUp</span><span class="o">);</span>
            <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentKeyUp</span><span class="o">);</span>
            <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseDown</span><span class="o">);</span>
        
        
            <span class="k">var</span> <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">();</span>
            
            <span class="k">if</span> <span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;reset&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFormReset</span><span class="o">);</span>
                <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;submit&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">createHiddenFields</span><span class="o">);</span>
        
            <span class="o">}</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Removing CustomEvent listeners.&quot;</span><span class="o">);</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">oParentNode</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oParentNode</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oElement</span><span class="o">);</span>
            
            <span class="o">}</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Removing from document.&quot;</span><span class="o">);</span>
        
            <span class="nx">delete</span> <span class="nx">m_oButtons</span><span class="o">[</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;id&quot;</span><span class="o">)];</span>

            <span class="nx">aButtons</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span><span class="o">,</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">NODE_NAME</span><span class="o">,</span> <span class="nx">oForm</span><span class="o">);</span> 

            <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">aButtons</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">aButtons</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;keypress&quot;</span><span class="o">,</span> 
                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">onFormKeyPress</span><span class="o">);</span>

            <span class="o">}</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Destroyed.&quot;</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="nx">fireEvent</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_sType</span> <span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="c">//  Disabled buttons should not respond to DOM events</span>
<span class="c"></span>        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">DOM_EVENTS</span><span class="o">[</span><span class="nx">p_sType</span><span class="o">]</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>
        
                <span class="k">return</span><span class="o">;</span>
        
            <span class="o">}</span>
        
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">p_sType</span><span class="o">,</span> 
                <span class="nx">p_aArgs</span><span class="o">);</span>
        
        <span class="o">},</span>
        
        
        <span class="c">/**</span>
<span class="c">        * @method toString</span>
<span class="c">        * @description Returns a string representing the button.</span>
<span class="c">        * @return {String}</span>
<span class="c">        */</span>
        <span class="nx">toString</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">return</span> <span class="o">(</span><span class="s2">&quot;Button &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;id&quot;</span><span class="o">));</span>
        
        <span class="o">}</span>
    
    <span class="o">});</span>
    
    
    <span class="c">/**</span>
<span class="c">    * @method YAHOO.widget.Button.onFormKeyPress</span>
<span class="c">    * @description &quot;keypress&quot; event handler for the button&#39;s form.</span>
<span class="c">    * @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">    * back by the event utility (YAHOO.util.Event).</span>
<span class="c">    */</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">onFormKeyPress</span> <span class="o">=</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">var</span> <span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">),</span>
            <span class="nx">nCharCode</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">),</span>
            <span class="nx">sNodeName</span> <span class="o">=</span> <span class="nx">oTarget</span><span class="o">.</span><span class="nx">nodeName</span> <span class="o">&amp;&amp;</span> <span class="nx">oTarget</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">(),</span>
            <span class="nx">sType</span> <span class="o">=</span> <span class="nx">oTarget</span><span class="o">.</span><span class="nx">type</span><span class="o">,</span>
    
            <span class="c">/*</span>
<span class="c">                Boolean indicating if the form contains any enabled or </span>
<span class="c">                disabled YUI submit buttons</span>
<span class="c">            */</span>
    
            <span class="nx">bFormContainsYUIButtons</span> <span class="o">=</span> <span class="kc">false</span><span class="o">,</span>
    
            <span class="nx">oButton</span><span class="o">,</span>
    
            <span class="nx">oYUISubmitButton</span><span class="o">,</span>   <span class="c">// The form&#39;s first, enabled YUI submit button</span>
<span class="c"></span>    
            <span class="c">/*</span>
<span class="c">                 The form&#39;s first, enabled HTML submit button that precedes any </span>
<span class="c">                 YUI submit button</span>
<span class="c">            */</span>
    
            <span class="nx">oPrecedingSubmitButton</span><span class="o">,</span>
            
    
            <span class="c">/*</span>
<span class="c">                 The form&#39;s first, enabled HTML submit button that follows a </span>
<span class="c">                 YUI button</span>
<span class="c">            */</span>
            
            <span class="nx">oFollowingSubmitButton</span><span class="o">;</span> 
    
    
        <span class="k">function</span> <span class="nx">isSubmitButton</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">var</span> <span class="nx">sId</span><span class="o">,</span>
                <span class="nx">oSrcElement</span><span class="o">;</span>
    
            <span class="nx">switch</span> <span class="o">(</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">())</span> <span class="o">{</span>
    
            <span class="nx">case</span> <span class="s2">&quot;INPUT&quot;</span><span class="o">:</span>
            <span class="nx">case</span> <span class="s2">&quot;BUTTON&quot;</span><span class="o">:</span>
            
                <span class="k">if</span> <span class="o">(</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">disabled</span><span class="o">)</span> <span class="o">{</span>
                    
                    <span class="k">if</span> <span class="o">(!</span><span class="nx">bFormContainsYUIButtons</span> <span class="o">&amp;&amp;</span> 
                        <span class="o">!</span><span class="nx">oPrecedingSubmitButton</span><span class="o">)</span> <span class="o">{</span>

                        <span class="nx">oPrecedingSubmitButton</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">;</span>

                    <span class="o">}</span>
                    
                    <span class="k">if</span> <span class="o">(</span><span class="nx">oYUISubmitButton</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oFollowingSubmitButton</span><span class="o">)</span> <span class="o">{</span>
                    
                        <span class="nx">oFollowingSubmitButton</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">;</span>
                    
                    <span class="o">}</span>
                
                <span class="o">}</span>

                <span class="k">break</span><span class="o">;</span>
            

            <span class="nx">default</span><span class="o">:</span>
            
                <span class="nx">sId</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
    
                <span class="k">if</span> <span class="o">(</span><span class="nx">sId</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="nx">oButton</span> <span class="o">=</span> <span class="nx">m_oButtons</span><span class="o">[</span><span class="nx">sId</span><span class="o">];</span>
        
                    <span class="k">if</span> <span class="o">(</span><span class="nx">oButton</span><span class="o">)</span> <span class="o">{</span>

                        <span class="nx">bFormContainsYUIButtons</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
                        <span class="k">if</span> <span class="o">(!</span><span class="nx">oButton</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>

                            <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="nx">oButton</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">);</span>
    
                            <span class="k">if</span> <span class="o">(!</span><span class="nx">oYUISubmitButton</span> <span class="o">&amp;&amp;</span>
                                <span class="o">(</span><span class="nx">oButton</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span> <span class="o">||</span> 
                                <span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span><span class="o">)))</span> 
                            <span class="o">{</span>

                                <span class="nx">oYUISubmitButton</span> <span class="o">=</span> <span class="nx">oButton</span><span class="o">;</span>
                            
                            <span class="o">}</span>
                        
                        <span class="o">}</span>
                        
                    <span class="o">}</span>
                
                <span class="o">}</span>

                <span class="k">break</span><span class="o">;</span>
    
            <span class="o">}</span>
    
        <span class="o">}</span>
    
    
        <span class="k">if</span> <span class="o">(</span><span class="nx">nCharCode</span> <span class="o">==</span> <span class="m">13</span> <span class="o">&amp;&amp;</span> <span class="o">((</span><span class="nx">sNodeName</span> <span class="o">==</span> <span class="s2">&quot;INPUT&quot;</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;text&quot;</span> <span class="o">||</span> 
            <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;password&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span> <span class="o">||</span> 
            <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;file&quot;</span><span class="o">))</span> <span class="o">||</span> <span class="nx">sNodeName</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">))</span>
        <span class="o">{</span>
    
            <span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsBy</span><span class="o">(</span><span class="nx">isSubmitButton</span><span class="o">,</span> <span class="s2">&quot;*&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    
    
            <span class="k">if</span> <span class="o">(</span><span class="nx">oPrecedingSubmitButton</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="c">/*</span>
<span class="c">                     Need to set focus to the first enabled submit button</span>
<span class="c">                     to make sure that IE includes its name and value </span>
<span class="c">                     in the form&#39;s data set.</span>
<span class="c">                */</span>
    
                <span class="nx">oPrecedingSubmitButton</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
            
            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span> <span class="o">(!</span><span class="nx">oPrecedingSubmitButton</span> <span class="o">&amp;&amp;</span> <span class="nx">oYUISubmitButton</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">if</span> <span class="o">(</span><span class="nx">oFollowingSubmitButton</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="c">/*</span>
<span class="c">                        Need to call &quot;preventDefault&quot; to ensure that </span>
<span class="c">                        the name and value of the regular submit button </span>
<span class="c">                        following the YUI button doesn&#39;t get added to the </span>
<span class="c">                        form&#39;s data set when it is submitted.</span>
<span class="c">                    */</span>
    
                    <span class="nx">Event</span><span class="o">.</span><span class="nx">preventDefault</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>
                
                <span class="o">}</span>
    
                <span class="nx">oYUISubmitButton</span><span class="o">.</span><span class="nx">submitForm</span><span class="o">();</span>
    
            <span class="o">}</span>
            
        <span class="o">}</span>
    
    <span class="o">};</span>
    
    
    <span class="c">/**</span>
<span class="c">    * @method YAHOO.widget.Button.addHiddenFieldsToForm</span>
<span class="c">    * @description Searches the specified form and adds hidden fields for  </span>
<span class="c">    * instances of YAHOO.widget.Button that are of type &quot;radio,&quot; &quot;checkbox,&quot; </span>
<span class="c">    * &quot;menu,&quot; and &quot;split.&quot;</span>
<span class="c">    * @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">    * one-html.html#ID-40002357&quot;&gt;HTMLFormElement&lt;/a&gt;} p_oForm Object reference </span>
<span class="c">    * for the form to search.</span>
<span class="c">    */</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">addHiddenFieldsToForm</span> <span class="o">=</span> <span class="k">function</span> <span class="o">(</span><span class="nx">p_oForm</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">var</span> <span class="nx">aButtons</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span>
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span><span class="o">,</span> 
                            <span class="s2">&quot;*&quot;</span><span class="o">,</span> 
                            <span class="nx">p_oForm</span><span class="o">),</span>
    
            <span class="nx">nButtons</span> <span class="o">=</span> <span class="nx">aButtons</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
            <span class="nx">oButton</span><span class="o">,</span>
            <span class="nx">sId</span><span class="o">,</span>
            <span class="nx">i</span><span class="o">;</span>
    
        <span class="k">if</span> <span class="o">(</span><span class="nx">nButtons</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Form contains &quot;</span> <span class="o">+</span> <span class="nx">nButtons</span> <span class="o">+</span> <span class="s2">&quot; YUI buttons.&quot;</span><span class="o">);</span>
    
            <span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">nButtons</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
    
                <span class="nx">sId</span> <span class="o">=</span> <span class="nx">aButtons</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">id</span><span class="o">;</span>
    
                <span class="k">if</span> <span class="o">(</span><span class="nx">sId</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="nx">oButton</span> <span class="o">=</span> <span class="nx">m_oButtons</span><span class="o">[</span><span class="nx">sId</span><span class="o">];</span>
        
                    <span class="k">if</span> <span class="o">(</span><span class="nx">oButton</span><span class="o">)</span> <span class="o">{</span>
           
                        <span class="nx">oButton</span><span class="o">.</span><span class="nx">createHiddenFields</span><span class="o">();</span>
                        
                    <span class="o">}</span>
                
                <span class="o">}</span>
            
            <span class="o">}</span>
    
        <span class="o">}</span>
    
    <span class="o">};</span>
    
    
    
    <span class="c">// Events</span>
<span class="c"></span>    
    
    <span class="c">/**</span>
<span class="c">    * @event focus</span>
<span class="c">    * @description Fires when the menu item receives focus.  Passes back a  </span>
<span class="c">    * single object representing the original DOM event object passed back by </span>
<span class="c">    * the event utility (YAHOO.util.Event) when the event was fired.  See </span>
<span class="c">    * &lt;a href=&quot;YAHOO.util.Element.html#addListener&quot;&gt;Element.addListener&lt;/a&gt; </span>
<span class="c">    * for more information on listening for this event.</span>
<span class="c">    * @type YAHOO.util.CustomEvent</span>
<span class="c">    */</span>
    
    
    <span class="c">/**</span>
<span class="c">    * @event blur</span>
<span class="c">    * @description Fires when the menu item loses the input focus.  Passes back  </span>
<span class="c">    * a single object representing the original DOM event object passed back by </span>
<span class="c">    * the event utility (YAHOO.util.Event) when the event was fired.  See </span>
<span class="c">    * &lt;a href=&quot;YAHOO.util.Element.html#addListener&quot;&gt;Element.addListener&lt;/a&gt; for  </span>
<span class="c">    * more information on listening for this event.</span>
<span class="c">    * @type YAHOO.util.CustomEvent</span>
<span class="c">    */</span>
    
    
    <span class="c">/**</span>
<span class="c">    * @event option</span>
<span class="c">    * @description Fires when the user invokes the button&#39;s option.  Passes </span>
<span class="c">    * back a single object representing the original DOM event (either </span>
<span class="c">    * &quot;mousedown&quot; or &quot;keydown&quot;) that caused the &quot;option&quot; event to fire.  See </span>
<span class="c">    * &lt;a href=&quot;YAHOO.util.Element.html#addListener&quot;&gt;Element.addListener&lt;/a&gt; </span>
<span class="c">    * for more information on listening for this event.</span>
<span class="c">    * @type YAHOO.util.CustomEvent</span>
<span class="c">    */</span>

<span class="o">})();</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div class="module">
                        <h4>Modules</h4>
                        <ul class="content">

                                <li class=""><a href="module_animation.html">animation</a></li>

                                <li class=""><a href="module_autocomplete.html">autocomplete</a></li>

                                <li class="selected"><a href="module_button.html">button</a></li>

                                <li class=""><a href="module_calendar.html">calendar</a></li>

                                <li class=""><a href="module_colorpicker.html">colorpicker</a></li>

                                <li class=""><a href="module_connection.html">connection</a></li>

                                <li class=""><a href="module_container.html">container</a></li>

                                <li class=""><a href="module_datasource.html">datasource</a></li>

                                <li class=""><a href="module_datatable.html">datatable</a></li>

                                <li class=""><a href="module_dom.html">dom</a></li>

                                <li class=""><a href="module_dragdrop.html">dragdrop</a></li>

                                <li class=""><a href="module_editor.html">editor</a></li>

                                <li class=""><a href="module_element.html">element</a></li>

                                <li class=""><a href="module_event.html">event</a></li>

                                <li class=""><a href="module_history.html">history</a></li>

                                <li class=""><a href="module_imageloader.html">imageloader</a></li>

                                <li class=""><a href="module_logger.html">logger</a></li>

                                <li class=""><a href="module_menu.html">menu</a></li>

                                <li class=""><a href="module_slider.html">slider</a></li>

                                <li class=""><a href="module_tabview.html">tabview</a></li>

                                <li class=""><a href="module_treeview.html">treeview</a></li>

                                <li class=""><a href="module_yahoo.html">yahoo</a></li>

                                <li class=""><a href="module_yuiloader.html">yuiloader</a></li>

                                <li class=""><a href="module_yuitest.html">yuitest</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a></li>
                                <li class=""><a href="YAHOO.widget.ButtonGroup.html">YAHOO.widget.ButtonGroup</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class="selected"><a href="button.js.html">button.js</a></li>
                                <li class=""><a href="buttongroup.js.html">buttongroup.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
	</div>
</div>
</body>
</html>
